Chinaunix首页 | 论坛 | 博客
  • 博客访问: 392561
  • 博文数量: 66
  • 博客积分: 1235
  • 博客等级: 少尉
  • 技术积分: 694
  • 用 户 组: 普通用户
  • 注册时间: 2010-03-05 12:24
文章分类

全部博文(66)

文章存档

2010年(66)

分类:

2010-06-21 11:21:09

*&---------------------------------------------------------------------*
*& Report  ZZWASTOR                                                    *
*&                                                                     *
*&---------------------------------------------------------------------*
*&                                                                     *
*&                                                                     *
*&---------------------------------------------------------------------*
REPORT ZZWASTOR .

*********************************************************************
* If you do not know the material document of the goods issue any   *
* more you can use transaction SE16.                                *
* - Type in table name MKPF                                         *
* - Type in the delivery note number in field XBLNR (always with    *
*   leading zeroes)                                                 *
* - Execute                                                         *
* - The Material document number of the goods issue for the deleted *
*   delivery will be shown.                                         *
*                                                                   *
*                                                                   *
*                                                                   *
* LF_BUDAT  =>  Posting date for the reversal                       *
* LF_MJAHR  =>  Posting year of the material document to reverse    *
* LF_MBLNR  =>  Goods issue document (with leading zeroes)          *
* LF_VBELN  =>  Delivery note number (with leading zeroes)          *
* LF_TEST   =>  When 'X' it is test mode only, otherwise GI will be *
*               cancelled                                           *
*********************************************************************

TABLES: MKPF, IMKPF, EMKPF, LIKP.

DATA:   BEGIN OF IMSEG OCCURS 0.
        INCLUDE STRUCTURE IMSEG.
DATA:   END OF IMSEG.

DATA:   BEGIN OF EMSEG OCCURS 0.
        INCLUDE STRUCTURE EMSEG.
DATA:   END OF EMSEG.


PARAMETERS: LF_BUDAT  LIKE SY-DATLO DEFAULT SY-DATLO OBLIGATORY,
            LF_MJAHR  LIKE MKPF-MJAHR DEFAULT SY-DATLO(4) OBLIGATORY,
            LF_MBLNR  LIKE MKPF-MBLNR OBLIGATORY,
            LF_VBELN  LIKE LIKP-VBELN OBLIGATORY,
            LF_TEST   TYPE C DEFAULT 'X'.

DATA:   MBLPO LIKE MSEG-ZEILE.

SELECT SINGLE * FROM MKPF WHERE MBLNR = LF_MBLNR
                          AND   MJAHR = LF_MJAHR
                          AND   XBLNR = LF_VBELN.

IF SY-SUBRC IS INITIAL.
  CALL FUNCTION 'MB_CANCEL_GOODS_MOVEMENT'
    EXPORTING
      BUDAT     = LF_BUDAT
      MBLNR     = LF_MBLNR
      MBLPO     = MBLPO
      MJAHR     = LF_MJAHR
      TCODE     = 'VL09'
      CALLED_BY = 'VL09'
    IMPORTING
      EMKPF     = EMKPF
    TABLES
      EMSEG     = EMSEG
      IMSEG     = IMSEG
    EXCEPTIONS
      OTHERS    = 1.

*... No error found, then it will be posted
  IF EMKPF-SUBRC EQ 1.
    IF LF_TEST IS INITIAL.
      CALL FUNCTION 'MB_POST_GOODS_MOVEMENT'
        EXPORTING
          XBLNR_SD = LF_VBELN
        IMPORTING
          EMKPF    = EMKPF
        EXCEPTIONS
          OTHERS   = 0.

      COMMIT WORK.
    WRITE: / 'Goods movement was cancelled successfully with document:',
            EMKPF-MBLNR.
    ELSE.
      WRITE: / 'Testmode: Goods movement could be cancelled !'.
    ENDIF.
  ELSE.
*... otherwise write an error-log
    LOOP AT EMSEG.
      WRITE: /
                EMSEG-MSGID,
                EMSEG-MSGNO,
                EMSEG-MSGTY,
                EMSEG-MSGV1,
               EMSEG-MSGV2,
               EMSEG-MSGV3,
               EMSEG-MSGV4.
    ENDLOOP.
    WRITE: / EMKPF-MSGID,
             EMKPF-MSGNO,
             EMKPF-MSGTY,
             EMKPF-MSGV1,
             EMKPF-MSGV2,
             EMKPF-MSGV3,
             EMKPF-MSGV4.

  ENDIF.
ELSE.
  WRITE: / 'Material document to reverse does not exsist'.
ENDIF.
                                              .
转载自Jack.Wu的博客:http://blog.csdn.net/CompassButton/archive/2007/09/29/1806383.aspx

阅读(2572) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~