Skip to Content
0
Former Member
Aug 21, 2007 at 09:02 AM

BAPI_INCOMINGINVOICE_CREATE - problem

612 Views

Hello,

I'm using BAPI_INCOMINGINVOICE_CREATE in the program. but it keep on giving the error message "GL account 12345 is not defined in chart of account". But when i run manually in se37 using the same data, it was okay. anyone has any idea. Below is the code. The GL account that enter is hard code, and not retrieve from the table.

thanks.

******************************

invoice_items-invoice_doc_item = 1.

invoice_items-po_number = itab_in-po_nbr.

invoice_items-po_item = itab_in-po_item.

APPEND invoice_items.

  • Prepare the accounting data

if not itab_in-oth_chg is initial.

Accounting-invoice_doc_item = 000001.

Accounting-xunpl = 'X'.

accounting-tax_code = itab_in-mwskz.

accounting-costcenter = itab_in-kostl.

accounting-item_amount = itab_in-oth_chg.

accounting-gl_account = '67899'.

append accounting.

endif.

  • Prepare the header

invheader-doc_date = itab_in-inv_date.

invheader-pstng_date = sy-datum .

invheader-comp_code = itab_in-bukrs.

invheader-invoice_ind = 'X'.

invheader-currency = itab_in-waers.

invheader-ref_doc_no = itab_in-inv_ref.

invheader-gross_amount = itab_in-ttl_inv_chg.

append invheader.

ENDLOOP.

  • Call the BAPI

CALL FUNCTION 'BAPI_INCOMINGINVOICE_CREATE'

EXPORTING

headerdata = invheader

IMPORTING

invoicedocnumber = v_invoice

fiscalyear = v_year

TABLES

itemdata = invoice_items

accountingdata = accounting

return = return.

  • Check the return code..

LOOP AT return

TRANSPORTING NO FIELDS

WHERE type = 'E' OR type = 'A'.

EXIT.

ENDLOOP.

IF sy-subrc = 0.

WRITE: / 'Error in creating'.

ELSE.

COMMIT WORK.

WRITE: / 'Invoice ', v_invoice, ' Year ', v_year, ' Created'.

ENDIF.