09-13-2009 5:49 AM
Hello ABAP experts,
Can some one help me with absolutely minimal data and typical sample data values for
BAPI_INCOMINGINVOICE_CREATE ?
Thanks in advance.
09-13-2009 8:21 AM
Hi ,
This block of code might help you.
LOOP AT it_final INTO <fs_final>.
*Creation of header for bapi
t_header-invoice_ind = 'X'.
t_header-doc_date = so_date-high.
t_header-pstng_date = so_date-high.
t_header-comp_code = 'RS01'.
t_header-gross_amount = <fs_final>-fin_amt .
t_header-currency = 'INR'.
t_header-pmnttrms = '0001'.
***************************************
LOOP AT it_mseg2 ASSIGNING <fs_mseg> WHERE lifnr = <fs_final>-lifnr.
wa_itemdata-invoice_doc_item = idx.
wa_itemdata-po_number = <fs_mseg>-ebeln.
wa_itemdata-po_item = <fs_mseg>-ebelp.
wa_itemdata-tax_code = 'V0'.
wa_itemdata-item_amount = <fs_mseg>-dmbtr .
wa_itemdata-quantity = <fs_mseg>-menge.
wa_itemdata-ref_doc = <fs_mseg>-mblnr.
wa_itemdata-ref_doc_year = <fs_mseg>-mjahr.
wa_itemdata-ref_doc_it = <fs_mseg>-zeile.
wa_itemdata-po_unit = <fs_mseg>-meins.
APPEND wa_itemdata TO it_itemdata.
CLEAR wa_itemdata.
ENDLOOP.
********************************************************************************************
CALL FUNCTION 'BAPI_INCOMINGINVOICE_CREATE'
EXPORTING
headerdata = t_header
ADDRESSDATA =
IMPORTING
invoicedocnumber = v_belnr
FISCALYEAR =
TABLES
itemdata = it_itemdata
ACCOUNTINGDATA =
glaccountdata = it_gl_account
MATERIALDATA =
TAXDATA =
WITHTAXDATA =
VENDORITEMSPLITDATA =
return = it_return .
IF v_belnr <> space.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X'.
wa_belnr-belnr = v_belnr.
wa_belnr-lifnr = <fs_mseg>-lifnr.
wa_belnr-mblnr = <fs_mseg>-mblnr.
APPEND wa_belnr TO it_belnr.
CLEAR wa_belnr.
REFRESH: it_itemdata,it_gl_account.
CLEAR: t_header.
ELSE.
LOOP AT it_return INTO wa_return.
CALL FUNCTION 'FORMAT_MESSAGE'
EXPORTING
id = wa_return-id
lang = sy-langu
no = wa_return-number
v1 = wa_return-message_v1
v2 = wa_return-message_v2
v3 = wa_return-message_v3
v4 = wa_return-message_v4
IMPORTING
msg = wa_return-message
EXCEPTIONS
not_found = 1
OTHERS = 2.
wa_error-srno = wa_return-message_v1.
wa_error-err_msg = wa_return-message.
APPEND wa_error TO it_error.
CLEAR: wa_error , wa_return.
ENDLOOP.
REFRESH: it_itemdata,it_gl_account.
CLEAR: t_header.
ENDIF.
ENDLOOP.
with regards
Nilesh
09-25-2009 10:35 AM
HI there,
I must say the use of the BAPI correclty will depend on what kind of invoice you actually want to create, i suggest you use the t-code BAPI and Materials Management->Invoice Verification->CreateFromData then check the documentation for the possibilities also find there the limitations of the BAPI.
Good day, Hope it helps, if you can however tell me what you want to use it for i will be in a better position to help.
12-25-2009 10:24 AM