zoukankan      html  css  js  c++  java
  • MM物料重新过账的代码摘抄

    *&---------------------------------------------------------------------*
    *& 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.
                                                  .
     

  • 相关阅读:
    PLSQL配置介绍
    jquery实现无外边框table
    以太坊白皮书
    区块链技术教程,如何从零开始学习以太坊及区块链
    Python机器学习中文版
    史上最全TensorFlow学习资源汇总
    什么是人工智能?终于说明白了
    Python 语音识别
    Step by Step 真正从零开始,TensorFlow详细安装入门图文教程!帮你完成那个最难的从0到1
    什么是加密经济学? 初学者终极指南
  • 原文地址:https://www.cnblogs.com/xiaomaohai/p/6157169.html
Copyright © 2011-2022 走看看