Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Error message in BAPI_INCOMINGINVOICE_CREATE1

kirankumark2
Participant
0 Kudos
519

Hi,

I have developed a program to create vendor invoice using BAPI_INCOMINGINVOICE_CREATE1, invoices are getting created but for some cases system throws a strange message "this billing document still includes messages" when I use BAPI_INCOMINGINVOICE_CREATE1 whereas when I use BAPI_INCOMINGINVOICE_SAVE invoice is getting created with Defined for background status. I have called BAPIS like below if First BAPI failed i am calling second BAPI with same data.

Note: This program executes in Background. This BAPI is called inside a LOOP statement. When we execute the same program in Foreground this message is not throwing and invoice is getting created with same data.

Some body help me to sort out as we are unable to Find the Root cause

CLEAR : lv_err.
CALL FUNCTION 'BAPI_INCOMINGINVOICE_CREATE1'
EXPORTING
headerdata = wa_inv_header
* ADDRESSDATA =
invoicestatus = gv_stat "'5'
IMPORTING
invoicedocnumber = w_invoice_num
fiscalyear = w_fiscalyear
TABLES
itemdata = t_item
taxdata = t_inv_tax
return = t_bapi_return.

LOOP AT t_bapi_return INTO wa_bapi_return.
IF ( wa_bapi_return-type = c_e ) OR ( wa_bapi_return-type = c_a ).
lv_err = 'X'.
ENDIF.
ENDLOOP.
IF lv_err = 'X'.
CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
IF flag1 IS INITIAL.
CLEAR : lv_err, wa_bapi_return.
REFRESH : t_bapi_return.
CALL FUNCTION 'BAPI_INCOMINGINVOICE_SAVE'
EXPORTING
headerdata = wa_inv_header
additionalheaderdata = wa_inv_add_header
refdoccategory = w_ref_doctype
* ar_docid = w_ar_docid
* ar_doctype = w_ar_doctype
IMPORTING
invoicedocnumber = w_invoice_num
fiscalyear = w_fiscalyear
TABLES
selectpo = t_inv_po
selectdelivery = t_inv_delivery
selectservice = t_inv_service
taxdata = t_inv_tax
return = t_bapi_return.

LOOP AT t_bapi_return INTO wa_bapi_return.
IF ( wa_bapi_return-type = c_e ) OR ( wa_bapi_return-type = c_a ).
lv_err = 'X'.
ENDIF.
ENDLOOP.
IF lv_err = 'X'.
CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
ELSE.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
WAIT = 'X'.
ENDIF.
ENDIF.

0 REPLIES 0