10-01-2010 9:42 AM
Hi,
I have searched in SDN before posting this question...
Using VF01, billing document is created.
Using VF02, the billing document will be released to accounting using the Release Flag.
I am trying to use the BAPI "BAPI BAPI_ACC_BILLING_POST" to do this in the background.
gd_documentheader-obj_type = ' BKPF'.
gd_documentheader-obj_key = '10001000102010'.
gd_documentheader-obj_sys = 'EUTCLNT201'.
gd_documentheader-username = sy-uname.
gd_documentheader-BUS_ACT = 'SD00'.
gd_documentheader-PSTNG_DATE = '20101001'.
gd_documentheader-COMP_CODE = '1000'.
gd_documentheader-DOC_TYPE = 'RV'.
In the BAPI Return, I am getting the following errors.
Error in document: BKPF 10001000102010 EUTCLNT201
No data was transferred in parameter ACCOUNTRECEIVABLE
I did not even knew what has to be passed to this BAPI.. After searching in SDN for quite some time, and reading the BAPI documentation, I got a rough idea.
Please let me know what is the error in the gd_documentheader data ??
I tried various combinations of objkey with companycode-billingdocument-fiscalyear..
Regards,
PR.
10-01-2010 9:54 AM
Accounting document will not created if you pass only header data. You have fill other structures such as ACCOUNTRECEIVABLE, ACCOUNTGL& CURRENCYAMOUNT. See the function module documentation for more details.
Filling of these structures will be some what similiar to the the BAPI [BAPI_ACC_DOCUMENT_POST.|http://wiki.sdn.sap.com/wiki/display/ABAP/BusinessTransactionEvent-RWBAPI01-ForAccountingDocument+Interface]
Parameters for structure DOCUMENTHEADER will be different for the BAPI_ACC_BILLING_POST.
Regards
Vinod
10-01-2010 9:54 AM
Accounting document will not created if you pass only header data. You have fill other structures such as ACCOUNTRECEIVABLE, ACCOUNTGL& CURRENCYAMOUNT. See the function module documentation for more details.
Filling of these structures will be some what similiar to the the BAPI [BAPI_ACC_DOCUMENT_POST.|http://wiki.sdn.sap.com/wiki/display/ABAP/BusinessTransactionEvent-RWBAPI01-ForAccountingDocument+Interface]
Parameters for structure DOCUMENTHEADER will be different for the BAPI_ACC_BILLING_POST.
Regards
Vinod
10-01-2010 11:28 AM
Hi Vinod,
Thanks for your reply.
Is there much difference between BAPI_ACC_DOCUMENT_POST and BAPI_ACC_BILLING_POST.
I am using BAPI_ACC_DOCUMENT_POST and still errors are being thrown by the BAPI..
"Account 1610101 in company code 1000 cannot be directly posted to".
Regards,
PR.
10-01-2010 11:32 AM
Yes, you cannot use similar code for both the BAPI. BAPI_ACC_BILLING_POST will create the accounting document with reference to the Billing document. See the Function module documentation to see the details of mandatory parameters to be passed.
Edit : Alternatively you can use the function module SD_INVOICE_RELEASE_TO_ACCOUNT which is used standard transaction VFX3 (Release Billing documents to Accounting). See include LV60PU16 - Function module VMCFA_ALV_DISPLAY - Line Number 167.
Regards
Vinod
Edited by: Vinod Kumar on Oct 1, 2010 4:09 PM
03-04-2015 10:09 AM
Dear Vinod ji
I am creating sale order,delivery,PGI and invoice through BAPIs in single program...
All is well...only problem is accounting document is not being generated along with invoice....i have to generate it manually in VF02. Kindly guide me how to get my invoice posted through bapi itself.
I CREATED SALE ORDER THROUGH BAPI_SALESORDER_CREATEFROMDAT2
my code FOR INVOICE is as follows
FORM INV_CREATE.
BREAK-POINT.
CALL FUNCTION 'BAPI_BILLINGDOC_CREATEMULTIPLE'
* EXPORTING
* CREATORDATAIN =
* TESTRUN =
* POSTING = 'X'
TABLES
BILLINGDATAIN = BILLDATA
* CONDITIONDATAIN =
* CCARDDATAIN =
TEXTDATAIN = TEXTDATAIN
ERRORS = ERRORS
RETURN = RETURN
SUCCESS = SUCC
.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
V_SEC = 1.
CALL FUNCTION 'FMCT_WAIT_FOR_UPDATE'
EXPORTING
I_SEC = V_SEC.
10-01-2010 9:59 AM
Hi Pathanjali,
Check the test program acc_bapi_test_billing to know how to pass to FM BAPI_ACC_BILLING_POST.
To the accounts receivable, you have to pass ITEMNO_ACC, CUSTOMER, ITEM_TEXT.
To the OBJKEY,
It consists of object key and object type. The object key consists of a reference document number and a reference organizational unit.
Example: 1000007899 00011996
billing document no. client and fiscal year
Hope it helps.
Sujay
10-05-2010 12:43 PM
<<Copy-paste from http://www.sapnet.ru/viewtopic.php?t=1945 deleted>>
Moderator Message: Yet another instance of you copy-pasting other people's work and passing off as your own.
Edited by: kishan P on Oct 6, 2010 10:30 AM
10-06-2010 6:17 AM
Hi.
I am sending u the sample code and it is working fine at my end. Please make changes in it according to ur requirement.
and then test it. Hope it will help u out.
DATA: gs_documentheader LIKE bapiache09.
DATA: BEGIN OF gt_documentheader OCCURS 0.
INCLUDE STRUCTURE bapiache09.
DATA: END OF gt_documentheader.
DATA: gs_accountgl LIKE bapiacgl09.
DATA: BEGIN OF gt_accountgl OCCURS 0.
INCLUDE STRUCTURE bapiacgl09.
DATA: END OF gt_accountgl.
DATA: gs_rec LIKE bapiacar09.
DATA: BEGIN OF gt_rec OCCURS 0.
INCLUDE STRUCTURE bapiacar09.
DATA: END OF gt_rec.
DATA: gs_accountpayable LIKE bapiacap09.
DATA: BEGIN OF gt_accountpayable OCCURS 0.
INCLUDE STRUCTURE bapiacap09.
DATA: END OF gt_accountpayable.
DATA: gs_currencyamount LIKE bapiaccr09.
DATA: BEGIN OF gt_currencyamount OCCURS 0.
INCLUDE STRUCTURE bapiaccr09.
DATA: END OF gt_currencyamount.
DATA: BEGIN OF return OCCURS 0.
INCLUDE STRUCTURE bapiret2.
DATA: END OF return.
*DATA: gv_obj_type LIKE bapiache09-obj_type VALUE 'BKPFF',
*gv_obj_key LIKE bapiache09-obj_key VALUE '3400000216',
**gv_obj_sys LIKE bapiache09-obj_sys VALUE 'DEVCLNT200'.
*
*gs_documentheader-obj_type = 'BKPFF'.
*gs_documentheader-obj_key = '3400000216'.
*gs_documentheader-obj_sys = 'DEVCLNT200'.
*"gs_documentheader-bus_act = 'BKPFF'.
gs_documentheader-username = sy-uname.
gs_documentheader-header_txt = 'test'.
gs_documentheader-comp_code = '1500'.
gs_documentheader-doc_date = sy-datum.
gs_documentheader-pstng_date = sy-datum.
gs_documentheader-doc_type = 'SA'.
APPEND gs_documentheader TO gt_documentheader.
*gs_accountpayable-itemno_acc = '2'.
*gs_accountpayable-vendor_no = '0060001439'.
*APPEND gs_accountpayable TO gt_accountpayable.
gs_accountgl-itemno_acc = '0000000001'.
gs_accountgl-gl_account = '0004690360'.
gs_accountgl-comp_code = '1500'.
gs_accountgl-pstng_date = sy-datum.
gs_accountgl-costcenter = '4150000000'.
APPEND gs_accountgl TO gt_accountgl.
gs_rec-itemno_acc = '0000000002'.
gs_rec-gl_account = '0004120250'.
gs_rec-COMP_CODE = '1500'.
gs_rec-customer = '0001000001'.
APPEND gs_rec TO gt_rec.
gs_currencyamount-itemno_acc = '0000000001'.
gs_currencyamount-currency = 'PKR'.
gs_currencyamount-amt_doccur = '20080'. "i_tab-repval.
APPEND gs_currencyamount TO gt_currencyamount.
gs_currencyamount-itemno_acc = '0000000002'.
gs_currencyamount-currency = 'PKR'.
gs_currencyamount-amt_doccur = '20080-'. "i_tab-repval.
APPEND gs_currencyamount TO gt_currencyamount.
BREAK-POINT.
CALL FUNCTION 'BAPI_ACC_DOCUMENT_POST'
EXPORTING
documentheader = gs_documentheader
* IMPORTING
* obj_type = gv_obj_type
* obj_key = gv_obj_key
* obj_sys = gv_obj_sys
TABLES
accountgl = gt_accountgl
accountreceivable = gt_rec
accountpayable = gt_accountpayable
currencyamount = gt_currencyamount
extension2 = extension2
return = return.
LOOP AT return WHERE type = 'E'.
EXIT.
ENDLOOP.
IF sy-subrc EQ 0.
WRITE: / 'BAPI call failed - debug and fix!'.
ELSE.
CLEAR return.
REFRESH return.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
* EXPORTING
* WAIT =
IMPORTING
return = return.
WRITE: / 'BAPI call worked!!'.
"WRITE: / obj_key, ' posted'.
ENDIF.