01-11-2006 4:25 PM
Hi,
I am trying to use the BAPI BAPI_ACC_BILLING_POST and having a problem. I am trying to post the customer invoice with doc type DR, and using an ABAP wrapper for the BAPI. I have used exclusive commit and also Commit FM. I filled the tax structures & also the Amount_base. Still I get the success message & no document created. Does anybody has some sample code who successfully used this BAPI.
Thanks in Advance.
Srini
01-11-2006 10:50 PM
Hi Srinivas
I create customer invoice (FB70) using BAPI_ACC_DOCUMENT_POST.
I execute COMMIT but haven't posted doc in system tables.
it looks like SAP bug (note 8842460).
many people write they have success, but nobody exactly knows the reason of non-posting although everyone does commit.
regards.
Oleg.
04-11-2007 2:21 PM
The BAPI is working absolutely fine. You have to pass correct data in correct parameters. then only the invoice will post and will update the database table BKPF and BSID.
Code should be like this...
*-----Making the Header
x_invheader-obj_type = 'BKPFF'. "Reference procedure
x_invheader-obj_key = '$'. "Object key
CONCATENATE sy-sysid 'CLNT' sy-mandt INTO
x_invheader-obj_sys. "Logical system of source document
x_invheader-bus_act = 'RFBU'. "Business Transaction
x_invheader-username = sy-uname. "User name
x_invheader-header_txt = x_header-col7. "Document Header Text
x_invheader-comp_code = x_header-col3. "Company Code
x_invheader-doc_date = v_doc_date. "Document Date in Document
x_invheader-pstng_date = v_pstng_date. "Posting Date in the Document
x_invheader-doc_type = 'DR'. "Reference Document Number
x_invheader-ref_doc_no = x_header-col4. "Reference Document Number
*-----For ACCOUNTRECEIVABLE
LOOP AT it_header INTO x_header.
x_bapiacar09-itemno_acc = '1'. "Accounting Document Line Item Number
*-----Filling zeros before Customer No
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = x_header-col2
IMPORTING
output = v_customer.
x_bapiacar09-customer = v_customer. "Customer Number 1
x_bapiacar09-comp_code = x_header-col3. "Company Code
APPEND x_bapiacar09 TO it_bapiacar09.
ENDLOOP.
*-----For ACCOUNTGL
LOOP AT it_lineitem INTO x_lineitem.
IF it_bapiacgl09 IS INITIAL.
v_itemno = 2.
ELSE.
v_itemno = v_itemno + 1.
ENDIF.
x_bapiacgl09-itemno_acc = v_itemno. "Accounting Document Line Item Number
*-----Filling zeros before G/L Account no
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = x_lineitem-col10
IMPORTING
output = v_gl_account.
x_bapiacgl09-gl_account = v_gl_account. "General Ledger Account
x_bapiacgl09-comp_code = x_lineitem-col11. "Company Code
x_bapiacgl09-profit_ctr = x_lineitem-col14. "Profit Center
x_bapiacgl09-item_text = x_lineitem-col15. "Item Text
APPEND x_bapiacgl09 TO it_bapiacgl09.
ENDLOOP.
*-----Clearing variable
CLEAR : v_itemno.
*-----For CURRENCYAMOUNT
LOOP AT it_header INTO x_header.
x_bapiaccr09-itemno_acc = '0000000001'. "Accounting Document Line Item Number
x_bapiaccr09-curr_type = '00'. "Currency type and valuation view
x_bapiaccr09-amt_doccur = x_header-col8. "Amount in document currency
x_bapiaccr09-currency = x_header-col9. "Currency Key
APPEND x_bapiaccr09 TO it_bapiaccr09.
ENDLOOP.
v_itemno_1 = 1.
LOOP AT it_lineitem INTO x_lineitem.
v_itemno_1 = v_itemno_1 + 1.
x_bapiaccr09_temp-itemno_acc = v_itemno_1. "Accounting Document Line Item Number
x_bapiaccr09_temp-curr_type = '00'. "Currency type and valuation view
CONCATENATE '-' x_lineitem-col12 INTO v_amount.
x_bapiaccr09_temp-amt_doccur = v_amount. "x_lineitem-col12. "Amount in document currency
x_bapiaccr09_temp-currency = x_lineitem-col13. "Currency Key
APPEND x_bapiaccr09_temp TO it_bapiaccr09.
ENDLOOP.
CLEAR : v_itemno_1.
*-----Calling BAPI for creating Customer Invoice
CALL FUNCTION 'BAPI_ACC_DOCUMENT_POST'
EXPORTING
documentheader = x_invheader
IMPORTING
obj_key = v_obj_key
TABLES
accountgl = it_bapiacgl09
accountreceivable = it_bapiacar09
currencyamount = it_bapiaccr09
return = return.
05-10-2007 2:55 PM
Hi Anirban,
I tried with the code provided by you to execute the BAPI ' BAPI_ACC_DOCUMENT_POST ' for the transaction FB70.
I tried to execute directly using SE37 as well as through a program.
I am getting the following error.
Error in document: BKPF $ QPTCLNT200
Incorrect entry in field OBJ_TYPE: BKPF
Could you please help me out ?
And ,i want to know the significance of BKPF and BKPFF i.e. what they means?
Thanks in advance,
Srini
Message was edited by:
Srinivasa Reddy
07-04-2007 7:32 AM
hi srini,
iam working on the same badi for fb70,
even iam getting the same error did u find the solution, please let me know.
sunil.....