BAPI_INCOMINGINVOICE_PARK'
.业务场景:对于有需要更新的si,需要对他做一次冲销后在进行收货,在冲销时可能会产生差异,因此需要调用这个bapi去修正差异。
DATA :WA_ HEADERDATA TYPE BAPI_INCINV_CREATE_HEADER.
DATA :IT_ ITEMDATA TYPE TABLE OF BAPI_INCINV_CREATE_ITEM WITH HEADER LINE.
DATA :IT_GLACCOUNTDATA TYPE TABLE OF BAPI_INCINV_CREATE_GL_ACCOUNT WITH HEADER LINE.
DATA :IT_MATERIALDATA TYPE TABLE OF BAPI_INCINV_CREATE_MATERIAL WITH HEADER LINE.
DATA :IT_RETURN LIKE TABLE OF BAPIRET2 WITH HEADER LINE.
DATA : WA_INVOICEDOCNUMBER TYPE BAPI_INCINV_FLD-INV_DOC_NO .
DATA : WA_ FISCALYEAR TYPE BAPI_INCINV_FLD-FISC_YEAR.
b.赋值
抬头赋值:
WA_ HEADERDATA-DOC_DATE = ‘20180628’ . 发票日期
WA_ HEADERDATA-PSTNG_DATE = ‘20180628’. 过账日期
WA_ HEADERDATA- REF_DOC_NO = XXX 参照(该场景此处填借贷标识)
WA_ HEADERDATA-CURRENCY = ‘CNY’ 币别
WA_ HEADERDATA- HEADER_TXT = XXXXXXXXX 抬头文本
WA_ HEADERDATA- BLINE_DATE = 20180628 基准日期
WA_ HEADERDATA-DIFF_INV = ‘S0001’ . 发票方
WA_ HEADERDATA-ALLOC_NMBR = XXXXX 分配
行项目赋值:
IT_ITEMDATA-PO_NUMBER = 1234567 采购订单号
APPEND IT_ ITEMDATA.
IT_GLACCOUNTDATA-GL_ACCOUNT = 6401040000 总账科目
IT_GLACCOUNTDATA- DB_CR_IND = XXX D/C
IT_GLACCOUNTDATA- BUS_AREA = 1101 业务中心
IT_GLACCOUNTDATA- PROFIT_CTR = 1101 利润中心
IT_GLACCOUNTDATA-ITEM_AMOUNT = 100000000. 金额
APPEND IT_GLACCOUNTDATA.
IT_ MATERIALDATA- MATERIAL = XXXXX 物料编码
IT_ MATERIALDATA- VAL_AREA = 1100 工厂
IT_ MATERIALDATA- DB_CR_IND = XXX 记(与先前的借贷标识相反)
IT_ MATERIALDATA- ITEM_AMOUNT = 100000000. 金额
APPEND IT_ MATERIALDATA.
注:行项目根据需求添加进内表中。
c.调用bapi
CALL FUNCTION 'BAPI_INCOMINGINVOICE_PARK'
EXPORTING
HEADERDATA = WA_HEADERDATA
IMPORTING
INVOICEDOCNUMBER = WA_INVOICEDOCNUMBER
FISCALYEAR = WA_FISCALYEAR
TABLES
ITEMDATA = IT_ITEMDATA
GLACCOUNTDATA = IT_GLACCOUNTDATA
MATERIALDATA = IT_ MATERIALDATA
RETURN = IT_RETURN.
READ TABLE IT_RETURN WITH KEY type = 'E'.
IF SY-SUBRC = 0.
CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK' .
ELSE. "无 E 类型消息
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
WAIT = 'X'.
ENDIF.