08-21-2007 10:02 AM
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.
08-21-2007 10:19 AM
hi dear,
when you are passing the GL ACCOUNT. You should use conversion exit. There is a mismatch with the interal format.
08-21-2007 10:22 AM
08-21-2007 10:31 AM
these are the FM
CONVERSION_EXIT_GLACT_INPUT
CONVERSION_EXIT_GLACT_OUTPUT
08-21-2007 12:15 PM
08-22-2007 2:51 AM
hi,
I don think the FM CONVERSION_EXIT_GLACT_INPUT is exist. i try to find in se37 but can't see any.
08-21-2007 12:25 PM
Hi,
Check the code below:
----
Build Invoice header *
----
Indicator
gs_headerdata-invoice_ind = gc_x.
Document Date
gs_headerdata-doc_date = gv_date1.
Posting Date
gs_headerdata-pstng_date = gv_date1.
Reference Document No
gs_headerdata-ref_doc_no = gs_itab5-docid.
Currency
gs_headerdata-currency = text-035.
Inorder to fetch the data from ALOGIS
PERFORM fetch_alogis_data.
Reading the data
READ TABLE gt_tax INTO gs_tax WITH KEY augru = gs_itab5-augru.
Document type
IF sy-subrc EQ gc_zero_num.
gs_headerdata-doc_type = gv_blart.
gs_headerdata-comp_code = gv_bukrs.
gs_itemdata-tax_code = gv_mwskz.
ENDIF.
Baseline Date
gs_headerdata-bline_date = gv_date1 .
*Tax Indicator
gs_headerdata-calc_tax_ind = gc_x.
LOOP AT gt_itab4 INTO gs_itab4. "#EC CI_NESTED
----
Build order item(s) *
----
Document Item
gs_itemdata-invoice_doc_item = gc_item.
Purchase Order Number
gs_itemdata-po_number = gs_itab4-vbeln.
Purchase Order Item
gs_itemdata-po_item = gs_itab4-posnn.
READ TABLE lt_itab5 INTO ls_itab5 WITH KEY ebeln = gs_itab4-vbeln BINARY SEARCH.
IF sy-subrc EQ gc_zero_num.
Quantity
gs_itemdata-quantity = ls_itab5-menge.
ENDIF.
gs_itemdata-po_unit = text-034.
Item Amount
lv_price = ls_itab5-menge * ls_itab5-netpr.
gs_itemdata-item_amount = lv_price.
gs_itemdata-taxjurcode = gc_jcode.
APPEND gs_itemdata TO gt_itemdata.
Gross Amount.
lv_gross = lv_price.
gs_headerdata-gross_amount = lv_gross.
*Call the BAPI to Create the Return Order
CALL FUNCTION 'BAPI_INCOMINGINVOICE_CREATE'
EXPORTING
headerdata = gs_headerdata
IMPORTING
invoicedocnumber = gv_invoice
fiscalyear = gv_year
TABLES
return = gt_return
itemdata = gt_itemdata.
Commit Work
PERFORM error.