![DEMO:MIRO针对无PO的物料发票校验BAPI_INCOMINGINVOICE_CREATE DEMO:MIRO针对无PO的物料发票校验BAPI_INCOMINGINVOICE_CREATE](https://i-blog.csdnimg.cn/blog_migrate/0738db98f3533ad8059cdd49fca07d16.jpeg)
抬头把相关数据填好后,就可以直接跳转到物料界面了,否则一直提示输入PO
REPORT zdemo_miro.
PARAMETERS p_s TYPE char1 RADIOBUTTON GROUP g1 DEFAULT 'X'.
PARAMETERS p_h TYPE char1 RADIOBUTTON GROUP g1.
DATA: ls_headerdata LIKE bapi_incinv_create_header,
lt_itemdata LIKE TABLE OF bapi_incinv_create_item,
ls_itemdata LIKE bapi_incinv_create_item,
lt_return LIKE TABLE OF bapiret2,
ls_return LIKE bapiret2,
lv_invoicedocnumber LIKE bapi_incinv_fld-inv_doc_no.
DATA: lv_item TYPE rblgp.
DATA: lv_gross TYPE bapi_rmwwr.
DATA:lt_materialdata LIKE TABLE OF bapi_incinv_create_material.
DATA:ls_materialdata LIKE bapi_incinv_create_material.
ls_materialdata-invoice_doc_item = 1.
ls_materialdata-material = 'XSWPTEST'.
IF p_s IS NOT INITIAL.
ls_materialdata-db_cr_ind = 'S'.
ELSE.
ls_materialdata-db_cr_ind = 'H'.
ENDIF.
ls_materialdata-item_amount = 10000.
ls_materialdata-quantity = 1.
ls_materialdata-tax_code = 'J8'.
ls_materialdata-base_uom = 'EA'.
ls_materialdata-val_area = 'S600'.
APPEND ls_materialdata TO lt_materialdata.
lv_gross = lv_gross 10000 10000 * 16 / 100.
*&header
CLEAR: ls_headerdata.
* "当采购订单行项目是正常订单时该标识必为X,为miro界面上的业务处理为1.发票否则为2.
* "贷方凭证(invoice_ind='X'表示miro界面最上部的业务处理是1.发票,invoice_ind='', 表示miro界面最上部的业务处理为2.贷方凭证)
IF p_s IS NOT INITIAL.
ls_headerdata-invoice_ind = 'X'."正常发票凭证
ELSE.
ls_headerdata-invoice_ind = ''."贷项凭证
ENDIF.
ls_headerdata-gross_amount = lv_gross.
ls_headerdata-bline_date = sy-datum.
ls_headerdata-diff_inv = 'XSWEY'.
ls_headerdata-ref_doc_no = 'S600'.
ls_headerdata-doc_date = sy-datum.
ls_headerdata-pstng_date = sy-datum.
ls_headerdata-comp_code = 'S600'..
ls_headerdata-currency = 'RMB'.
ls_headerdata-currency_iso = 'RMB'.
ls_headerdata-calc_tax_ind = 'X'.
ls_headerdata-pmnttrms = '0001'.
ls_headerdata-item_text = 'text'.
ls_headerdata-gross_amount = lv_gross.
CALL FUNCTION 'BAPI_INCOMINGINVOICE_CREATE'
EXPORTING
headerdata = ls_headerdata
IMPORTING
invoicedocnumber = lv_invoicedocnumber
TABLES
itemdata = lt_itemdata
materialdata = lt_materialdata
return = lt_return.
IF lv_invoicedocnumber IS NOT INITIAL .
WRITE lv_invoicedocnumber.
COMMIT WORK AND WAIT.
ENDIF.