IMPORT 參數
MATERIALDOCUMENT : 要迴轉的 MM Doc
MATDOCUMENTYEAR ; 要迴轉傳票的 MM Doc Year
GOODSMVT_PSTNG_DATE : 過帳的日期
GOODSMVT_PR_UNAME : 過帳的 User ID
EXPORT 參數
GOODSMVT_HEADRET : 產生的回轉 MM Doc 相關資訊
TABLES 參數
RETURN : 執行的 Return Message
GOODSMVT_MATDOCITEM : 如果非整張文件迴轉,則可以 By Item 迴轉
一、MM Document Reversed
SAMPLE CODE :
REPORT Z_BAPI_GOODSMVT_CANCEL.
DATA:
L_MATERIALDOCUMENT TYPE BAPI2017_GM_HEAD_02-MAT_DOC,
L_MATDOCUMENTYEAR TYPE BAPI2017_GM_HEAD_02-DOC_YEAR,
L_GOODSMVT_PSTNG_DATE TYPE BAPI2017_GM_HEAD_02-PSTNG_DATE,
L_GOODSMVT_PR_UNAME TYPE BAPI2017_GM_HEAD_01-PR_UNAME.
DATA:
L_GOODSMVT_HEADRET LIKE BAPI2017_GM_HEAD_RET.
DATA:
L_RETURN LIKE STANDARD TABLE OF BAPIRET2 WITH HEADER LINE.
L_MATERIALDOCUMENT = '5000001712'.
L_MATDOCUMENTYEAR = '2017'.
L_GOODSMVT_PSTNG_DATE = '20170819'.
L_GOODSMVT_PR_UNAME = SY-UNAME.
CALL FUNCTION 'BAPI_GOODSMVT_CANCEL'
EXPORTING
MATERIALDOCUMENT = L_MATERIALDOCUMENT
MATDOCUMENTYEAR = L_MATDOCUMENTYEAR
GOODSMVT_PSTNG_DATE = L_GOODSMVT_PSTNG_DATE
GOODSMVT_PR_UNAME = L_GOODSMVT_PR_UNAME
IMPORTING
GOODSMVT_HEADRET = L_GOODSMVT_HEADRET
TABLES
RETURN = L_RETURN
* GOODSMVT_MATDOCITEM =
.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
WAIT = 'X'
* IMPORTING
* RETURN =
.
WRITE L_GOODSMVT_HEADRET.
執行後即可產生回轉文件,在 PO History 產生 102 迴轉文件
如果只想迴轉文件中的一個 Item 時,則可使用參數 GOODSMVT_MATDOCITEM
SAMPLE CODE :
REPORT Z_BAPI_GOODSMVT_CANCEL.
DATA:
L_MATERIALDOCUMENT TYPE BAPI2017_GM_HEAD_02-MAT_DOC,
L_MATDOCUMENTYEAR TYPE BAPI2017_GM_HEAD_02-DOC_YEAR,
L_GOODSMVT_PSTNG_DATE TYPE BAPI2017_GM_HEAD_02-PSTNG_DATE,
L_GOODSMVT_PR_UNAME TYPE BAPI2017_GM_HEAD_01-PR_UNAME.
DATA:
L_GOODSMVT_HEADRET LIKE BAPI2017_GM_HEAD_RET.
DATA:
L_RETURN LIKE STANDARD TABLE OF BAPIRET2 WITH HEADER LINE.
DATA:
LT_GOODSMVT_MATDOCITEM LIKE STANDARD TABLE OF BAPI2017_GM_ITEM_04 WITH HEADER LINE.
L_MATERIALDOCUMENT = '5000001736'.
L_MATDOCUMENTYEAR = '2017'.
L_GOODSMVT_PSTNG_DATE = '20170819'.
L_GOODSMVT_PR_UNAME = SY-UNAME.
LT_GOODSMVT_MATDOCITEM-MATDOC_ITEM = '0002'.
APPEND LT_GOODSMVT_MATDOCITEM. CLEAR LT_GOODSMVT_MATDOCITEM.
CALL FUNCTION 'BAPI_GOODSMVT_CANCEL'
EXPORTING
MATERIALDOCUMENT = L_MATERIALDOCUMENT
MATDOCUMENTYEAR = L_MATDOCUMENTYEAR
GOODSMVT_PSTNG_DATE = L_GOODSMVT_PSTNG_DATE
GOODSMVT_PR_UNAME = L_GOODSMVT_PR_UNAME
IMPORTING
GOODSMVT_HEADRET = L_GOODSMVT_HEADRET
TABLES
RETURN = L_RETURN
GOODSMVT_MATDOCITEM = LT_GOODSMVT_MATDOCITEM.
.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
WAIT = 'X'
* IMPORTING
* RETURN =
.
WRITE L_GOODSMVT_HEADRET.
即可看到目前產生的迴轉文件只有其中一個 Item
沒有留言:
張貼留言