05-21-2009 9:06 AM
hi Friends..
I have created a finction module using BAPI "BAPI_INCOMINGINVOICE_CREATE"
I used some fields as a input for FM,from bapi's header data.
I used all the rest of the tables and fields from BAPI.
when I checked relevant internal tabel it shows the entered values..
-
itab1-INVOICE_IND = INVOICE_IND.
itab1-DOC_DATE = DOC_DATE.
itab1-PSTNG_DATE = PSTNG_DATE.
itab1-COMP_CODE = COMP_CODE.
itab1-CURRENCY = CURRENCY.
itab1-GROSS_AMOUNT = GROSS_AMOUNT.
append itab1.
I_ITEM-INVOICE_DOC_ITEM = ITEMDATA-INVOICE_DOC_ITEM.
I_ITEM-PO_NUMBER = ITEMDATA-PO_NUMBER.
I_ITEM-TAX_CODE = ITEMDATA-TAX_CODE.
I_ITEM-ITEM_AMOUNT = ITEMDATA-ITEM_AMOUNT.
I_ITEM-QUANTITY = ITEMDATA-QUANTITY.
I_ITEM-PO_UNIT = ITEMDATA-PO_UNIT.
append I_ITEM.
I_TAX-TAX_CODE = TAXDATA-TAX_CODE.
I_TAX-TAX_AMOUNT = TAXDATA-TAX_AMOUNT.
append I_TAX.
-
if I Passed these values to BAPI_INCOMINGINVOICE_CREATE, nothing comes in the bapi's output.
That means no data's comes in DOCUMENT NO and FISCAL YEAR field of BAPI.
I dont know what is the exact problem behind this.plz help me to resolve.
Thanks
Gowrishankar
05-21-2009 9:42 AM
I have successful working of BAPI_INCOMINGINVOICE_CREATE, apparently this is not so straight forward so bear with this:
I suggest you retrieve your PO information first by calling FM : BAPI_PO_CREATE because you need the PO History from the PO itself for the creation of IV. Reason being, for GR based IV PO you will need the GR document as the reference in the IV creation. The information is capture in the Hsitory table in the FM below.
call function 'BAPI_PO_GETDETAIL'
exporting
purchaseorder = purchaseorderz
items = 'X'
history = 'X'
importing
po_header = po_header
tables
po_items = po_items
po_item_history = po_items_history
return = po_return_vef
move corresponding data from PO_ITEMS table to your IV item table(itemdata), but for each PO item, you need to check if it has the GR history then you will need these fields PO_ITEMS_HISTORY-REF_DOC_YR, PO_ITEMS_HISTORY-REF_DOC_doc and PO_ITEMS_HISTORY-REF_DOC_IT
move :
po_items_history-ref_doc_yr to itemdata-ref_doc_year,
po_items_history-ref_doc to itemdata-ref_doc,
po_items_history-ref_doc_it to itemdata-ref_doc_it.
then you can call FM : CALCULATE_TAX_FROM_NET_AMOUNT to calculate your tax amount base on the tax code that you have and the transaction amount to derive the invoice amount.
assign variable w_totwr = invoice amount + tax_amount.
move these values to the invoice header table: where headerdata is the table for invoice header
Header Data
move:
'X' to headerdata-invoice_ind,
'RE' to headerdata-doc_type,
sy-datum to headerdata-doc_date,
sy-datum to headerdata-pstng_date,
po_header_vef-vendor to headerdata-diff_inv,
po_header_vef-co_code to headerdata-comp_code,
po_header_vef-currency to headerdata-currency,
w_totwr to headerdata-gross_amount.
append headerdata.
Tax Data
move :
'V0' to taxdata-tax_code,
tax_amount to taxdata-tax_amount.
append taxdata.
Vendor Split
move :
'000001' to vendoritemsplitdata-split_key,
w_totwr to vendoritemsplitdata-split_amount.
append vendoritemsplitdata.
Finally call the FM:
call function 'BAPI_INCOMINGINVOICE_CREATE'
exporting
headerdata = headerdata
importing
invoicedocnumber = invoicedocnumber
FISCALYEAR =
tables
itemdata = itemdata
taxdata = taxdata
vendoritemsplitdata = vendoritemsplitdata
return = ireturn
***********************************************************************************
As such you should have invoice created.
ensure you perform the commit function using FM below if invoice number is retrieved.
call function 'BAPI_TRANSACTION_COMMIT'
exporting
wait = mywait.
Hope this helps.
Regards,
Andrew
05-21-2009 9:15 AM
Hi,
First check executing the BAPI from SE37, by passing the similar values from the internal tables. I think there is some authorization issue.
Regards,
Santhosh.
05-21-2009 9:15 AM
hai gowri what is the error u r getting in the return table
based on that u have to pass the correct values.
afzal
05-21-2009 9:20 AM
Hi,
Please check with this FM "BAPI_INCOMINGINVOICE_SAVE".
Hope this will help you.
Regards,
Smart Varghese
05-21-2009 9:42 AM
I have successful working of BAPI_INCOMINGINVOICE_CREATE, apparently this is not so straight forward so bear with this:
I suggest you retrieve your PO information first by calling FM : BAPI_PO_CREATE because you need the PO History from the PO itself for the creation of IV. Reason being, for GR based IV PO you will need the GR document as the reference in the IV creation. The information is capture in the Hsitory table in the FM below.
call function 'BAPI_PO_GETDETAIL'
exporting
purchaseorder = purchaseorderz
items = 'X'
history = 'X'
importing
po_header = po_header
tables
po_items = po_items
po_item_history = po_items_history
return = po_return_vef
move corresponding data from PO_ITEMS table to your IV item table(itemdata), but for each PO item, you need to check if it has the GR history then you will need these fields PO_ITEMS_HISTORY-REF_DOC_YR, PO_ITEMS_HISTORY-REF_DOC_doc and PO_ITEMS_HISTORY-REF_DOC_IT
move :
po_items_history-ref_doc_yr to itemdata-ref_doc_year,
po_items_history-ref_doc to itemdata-ref_doc,
po_items_history-ref_doc_it to itemdata-ref_doc_it.
then you can call FM : CALCULATE_TAX_FROM_NET_AMOUNT to calculate your tax amount base on the tax code that you have and the transaction amount to derive the invoice amount.
assign variable w_totwr = invoice amount + tax_amount.
move these values to the invoice header table: where headerdata is the table for invoice header
Header Data
move:
'X' to headerdata-invoice_ind,
'RE' to headerdata-doc_type,
sy-datum to headerdata-doc_date,
sy-datum to headerdata-pstng_date,
po_header_vef-vendor to headerdata-diff_inv,
po_header_vef-co_code to headerdata-comp_code,
po_header_vef-currency to headerdata-currency,
w_totwr to headerdata-gross_amount.
append headerdata.
Tax Data
move :
'V0' to taxdata-tax_code,
tax_amount to taxdata-tax_amount.
append taxdata.
Vendor Split
move :
'000001' to vendoritemsplitdata-split_key,
w_totwr to vendoritemsplitdata-split_amount.
append vendoritemsplitdata.
Finally call the FM:
call function 'BAPI_INCOMINGINVOICE_CREATE'
exporting
headerdata = headerdata
importing
invoicedocnumber = invoicedocnumber
FISCALYEAR =
tables
itemdata = itemdata
taxdata = taxdata
vendoritemsplitdata = vendoritemsplitdata
return = ireturn
***********************************************************************************
As such you should have invoice created.
ensure you perform the commit function using FM below if invoice number is retrieved.
call function 'BAPI_TRANSACTION_COMMIT'
exporting
wait = mywait.
Hope this helps.
Regards,
Andrew