在执行BAPI_INCOMINGINVOICE_CREATE 之后,正常生成了发票号,但是系统会dump
数据会回滚
dump如下
查阅后得知相关note:1894901
原因是在填写税行的时候,输入了多行,将数据合并为一行后即可
代码如下:
ls_headerdata-invoice_ind = 'X'.
ls_headerdata-doc_type = 'RE'.
ls_headerdata-doc_date = sy-datum.
ls_headerdata-pstng_date = sy-datum.
ls_headerdata-bline_date = sy-datum.
ls_headerdata-comp_code = 'CV01'.
ls_headerdata-currency = 'CNY'.
ls_headerdata-del_costs_taxc = 'J2'.
SELECT * INTO TABLE lt_ekpo
FROM ekpo
WHERE ebeln = cs_head-ebeln_cv01.
IF sy-subrc = 0.
LOOP AT lt_ekpo INTO ls_ekpo.
CLEAR:lv_tax_amount.
lv_item = lv_item + 10. "发票行项目号
PERFORM frm_get_tax_by_net_amount USING 'CV01' 'J2' 'CNY' ls_ekpo-netwr
CHANGING lv_tax_amount.
ls_headerdata-gross_amount = ls_headerdata-gross_amount + ls_ekpo-netwr + lv_tax_amount.
lw_itemdata-invoice_doc_item = lv_item.
lw_itemdata-po_number = ls_ekpo-ebeln.
lw_itemdata-po_item = ls_ekpo-ebelp.
lw_itemdata-po_unit = ls_ekpo-meins.
lw_itemdata-quantity = ls_ekpo-menge.
lw_itemdata-item_amount = ls_ekpo-netwr.
lw_itemdata-ref_doc = cs_head-mblnr_cv01.
lw_itemdata-ref_doc_year = cs_head-mjahr_cv01.
lw_itemdata-ref_doc_it = ls_ekpo-ebelp+0(4).
APPEND lw_itemdata TO lt_itemdata[].
* fill tax data
lw_taxdata-tax_code = 'J2'.
lw_taxdata-tax_amount = lw_taxdata-tax_amount + lv_tax_amount.
lw_taxdata-tax_base_amount = lw_taxdata-tax_base_amount + ls_ekpo-netwr.
ENDLOOP.
APPEND lw_taxdata TO lt_taxdata.
ENDIF.
CALL FUNCTION 'BAPI_INCOMINGINVOICE_CREATE'
EXPORTING
headerdata = ls_headerdata
IMPORTING
invoicedocnumber = lv_invoicedocnumber
fiscalyear = lv_fiscalyear
TABLES
itemdata = lt_itemdata[]
taxdata = lt_taxdata[]
return = lt_return[].