但與 MIGO Reversed 的 BAPI_GOODSMVT_CANCEL 不同在於,BAPI_INCOMINGINVOICE_CANCEL 無法 Reversed By Item,因此如同 MR8M 在迴轉時需整張文件迴轉,但通常發票驗證會輸入 Invoice 理論上 Invoice 也不能重覆過帳,只有再迴轉後才能再進行過帳,因此無法 By Item 迴轉也相當何理
如下圖當 MM doc 5000001736 be reversed by 5000001737,因此 Invoice 也需要一併被回轉,則可以下方 Code 進行回轉
SAMPLE CODE :
REPORT Z_BAPI_GOODSMVT_CANCEL.
DATA:
INVOICEDOCNUMBER LIKE BAPI_INCINV_FLD-INV_DOC_NO,
FISCALYEAR LIKE BAPI_INCINV_FLD-FISC_YEAR,
REASONREVERSAL LIKE BAPI_INCINV_FLD-REASON_REV,
POSTINGDATE LIKE BAPI_INCINV_FLD-PSTNG_DATE.
DATA:
INVOICEDOCNUMBER_REVERSAL LIKE BAPI_INCINV_FLD-INV_DOC_NO,
FISCALYEAR_REVERSAL LIKE BAPI_INCINV_FLD-FISC_YEAR.
DATA:
RETURN LIKE STANDARD TABLE OF BAPIRET2 WITH HEADER LINE.
INVOICEDOCNUMBER = '5105601987'.
FISCALYEAR = '2017'.
REASONREVERSAL = '01'. "如果迴轉在同一天可不
POSTINGDATE = '20170819'.
CALL FUNCTION 'BAPI_INCOMINGINVOICE_CANCEL'
EXPORTING
INVOICEDOCNUMBER = INVOICEDOCNUMBER
FISCALYEAR = FISCALYEAR
REASONREVERSAL = REASONREVERSAL
POSTINGDATE = POSTINGDATE
IMPORTING
INVOICEDOCNUMBER_REVERSAL = INVOICEDOCNUMBER_REVERSAL
FISCALYEAR_REVERSAL = FISCALYEAR_REVERSAL
TABLES
RETURN = RETURN
.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
WAIT = 'X'
* IMPORTING
* RETURN =
.
WRITE: INVOICEDOCNUMBER_REVERSAL, '/', FISCALYEAR_REVERSAL.
其中傳入的參數值即同 MR8M 要輸入的值,而 POSTINGDATE 為 OPTION 因此也可不指定
執行後即可取得迴轉的 Invoice 與 Year
則可看到目前 Invoice 同上方迴轉的文件
沒有留言:
張貼留言