‎2007 Apr 18 2:28 PM
Helo dear colegues,
I have to create a central posting interface (ABAP program) for GL postings with the data read from Legacy system. From collected data we create a file on Appl.server. The file is then read by a diferent interface (another ABAP program), which has to post the document in from that file.
Main problem is that the file can contain more than 950 line items, and what I would like to know is how can i process the document in the file.
My idea was to split the file by ABAP into few files that woul be balanced and than post them thru RFBIBl00 that would generate few FI dobuments with the reference to one Legacy document. The only problem is that the customer doesn't want to have partialy posted documents.
Let's say ve have 1100 line items in a file, ve create 2 files, 1st with 950 line items and 2nd with 250. If the 1st one pases OK, the document is posted in FI, but if the other
one breaks, 1st one shouldn't pass and we would have to reverse the proces.
Is there any way of controling/simulating/checking if all parts(file) of the original legacy document will succed, speaking from the ABAP point of view, and NOT to post the document if their parts are corrupted.
Because, if the process breaks, we have to send the error code and message text back
to the Legacy system and update the status of errorenous document in legacy system, so that the interface can process it again, when the error is corrected manualy on legacy or SAP side (depending on the error).
Interfaces that are posting their files, were planned to use RFBIBBL00, and the stucture
of the created files on appl server is in RFBIBL format.
Can the documents be posted with more line items by the BAPI_ACC_DOCUMENT_POST, or bapi just uses RFBIBL on some level.
Any hint or possible solution?
I noticed the check file tick on RFBIBL, and BAPI_ACC_DOCUMENT_CHECK?
Does anybody have some experience over this topic?
Maybe a completely different approach?
Thanx on any answer, i won't be chap on reward points
Cheers, BaX
‎2007 Apr 18 3:21 PM
Hi ..
The BAPI BAPI_ACC_DOCUMENT_POST is the best option.
In you case .. since you have to post 2 documents... so you can call this BAPI twice..
and commit only if it was successful both the times.
Use BAPI_TRANSACTION_COMMIT to commit work.
Just for Info : There is no way you can post more than 1000 lines .. becoz the line item is always a 3 char field.
So you will have to split it into 2 docs.
The Bapi is actually self-explanatory ... still if you find it confusing .. feel free to come back..
Good Luck.
‎2007 Apr 18 2:36 PM
Hi Bax,
Bapi will do the job.
What I can advice if you want to check / Test .
Just create a p_test parameter ( checkbox ).
Then in your code put a logic like this :
* call BAPI-function in this system
CALL FUNCTION 'BAPI_ACC_DOCUMENT_POST'
EXPORTING
documentheader = documentheader
IMPORTING
obj_type = l_type
obj_key = l_key
obj_sys = l_sys
TABLES
accountgl = accountgl
accountpayable = accountpayable
currencyamount = currencyamount
accounttax = accounttax
extension1 = extension1
return = return.
IF p_test EQ 'X'.
* TEST
CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
ELSE.
* COMMIT
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
ENDIF.
If u want to analyse the posting just loop at the <b>return</b> table which contains error and wrning msg !
Hope this helps,
Erwan
‎2007 Apr 18 3:21 PM
Hi ..
The BAPI BAPI_ACC_DOCUMENT_POST is the best option.
In you case .. since you have to post 2 documents... so you can call this BAPI twice..
and commit only if it was successful both the times.
Use BAPI_TRANSACTION_COMMIT to commit work.
Just for Info : There is no way you can post more than 1000 lines .. becoz the line item is always a 3 char field.
So you will have to split it into 2 docs.
The Bapi is actually self-explanatory ... still if you find it confusing .. feel free to come back..
Good Luck.
‎2007 Apr 19 3:05 PM
You can also use the bapi BAPI BAPI_ACC_DOCUMENT_<b>CHECK</b> in case of a test run --> no need for a rollback.
The checks will be exactly the same as the post BAPI.
Also, there is a more precise BAPI available specially for GL postings: BAPI_ACC_GL_POSTING_POST and BAPI_ACC_GL_POSTING_CHECK.
Kind Regards,
Bart
Message was edited by:
bart pelsmaekers
‎2007 Nov 19 11:47 PM
Hello. I would like to append onto this thread with my own question if I may.
I have been attempting to convert an ABAP BDC program (for Tcod F-02) to a BAPI using BAPI_ACC_GL_POSTING_CHECK and BAPI_ACC_GL_POSTING_POST.
I have succeded to the point that I get an error return from the "CHECK" with the following messages:
BAPI_ACC_GL_POSTING_CHECK return messages.
609 Error in document: BKPFF $ ED1CLNT230
507 G/L account 8432200 is not defined in chart of accounts BTCA
'BTCA' is our Chart of Accounts. This and other G/L's that I have attempted to use are in our Chart of Accounts. I can manually perform Tcode F-02 using the information that I send to the BAPI and generate a CO document.
Following is my ABAP Code:
g_tab_account_gl-itemno_acc = sy-tabix.
g_tab_account_gl-gl_account = g_wrk_exp_d-hkont.
g_tab_account_gl-bus_area = ''.
g_tab_account_gl-comp_code = g_sav_bukrs.
g_tab_account_gl-pstng_date(4) = g_wrk_exp_h-bldat+4(4).
g_tab_account_gl-pstng_date+4(4) = g_wrk_exp_h-bldat(4).
g_tab_account_gl-fisc_year = g_wrk_exp_h-bldat+4(4).
g_tab_account_gl-item_text = g_wrk_exp_h-bktxt.
g_tab_account_gl-doc_type = 'SA'.
g_tab_account_gl-AC_DOC_NO
g_tab_account_gl-FIS_PERIOD = sy-datum+4(2).
g_tab_account_gl-STAT_CON
g_tab_account_gl-REF_KEY_1
g_tab_account_gl-REF_KEY_2
g_tab_account_gl-REF_KEY_3
g_tab_account_gl-CUSTOMER
g_tab_account_gl-VENDOR_NO
g_tab_account_gl-ALLOC_NMBR
g_tab_account_gl-costcenter = g_sav_kostl.
g_tab_account_gl-ACTTYPE
g_tab_account_gl-ORDERID
g_tab_account_gl-ORIG_GROUP
g_tab_account_gl-COST_OBJ
g_tab_account_gl-profit_ctr = g_wrk_exp_d-prctr.
g_tab_account_gl-PART_PRCTR
g_tab_account_gl-wbs_element = g_wrk_exp_d-posid.
g_tab_account_gl-NETWORK
g_tab_account_gl-ROUTING_NO
g_tab_account_gl-ORDER_ITNO
g_tab_account_gl-ACTIVITY
g_tab_account_gl-PLANT
g_tab_account_gl-SALES_ORD
g_tab_account_gl-S_ORD_ITEM
APPEND g_tab_account_gl TO g_tab_account_gl.
g_tab_currency_amount-itemno_acc = sy-tabix. "Accounting Document Line Item Number
g_tab_currency_amount-curr_type = '00'. "Currency type and valuation view
g_tab_currency_amount-currency = 'USD'. "Currency Key
g_tab_currency_amount-currency_iso = 'INR'. "ISO code currency
IF g_wrk_exp_d-bschl = '50'.
g_tab_currency_amount-amt_doccur = g_wrk_exp_d-wrbtr. "Amount in document currency
ELSE.
g_tab_currency_amount-amt_doccur = g_wrk_exp_d-wrbtr * -1. "Amount in document currency
ENDIF.
MOVE g_wrk_exp_d-wrbtr TO g_tab_currency_amount-amt_doccur. "Amount in document currency
g_tab_currency_amount-exch_rate = "Exchange rate
g_tab_currency_amount-exch_rate_v = "Indirect Quoted Exchange Rate
APPEND g_tab_currency_amount TO g_tab_currency_amount.
ENDLOOP.
*ITEMNO_ACC POSNR_ACC NUMC 10 0 Accounting Document Line Item Number
*CURR_TYPE CURTP CHAR 2 0 Currency type and valuation view
*CURRENCY WAERS CUKY 5 0 Currency Key
*CURRENCY_ISO WAERS_ISO CHAR 3 0 ISO code currency
*AMT_DOCCUR BAPIWRBTR DEC 23 4 Amount in document currency
*EXCH_RATE KURSF DEC 9 5 Exchange rate
*EXCH_RATE_V UKURSM DEC 9 5 Indirect Quoted Exchange Rate
CLEAR: g_wrk_message. REFRESH: g_tab_message.
***************************************************
Start of code to populate Tables for BAPI. **
**
First is the document header -> g_tab_doc_hdr **
BAPIACHE08 **
***************************************************
g_tab_doc_hdr-obj_type = 'RFBU'. "Reference Procedure
g_tab_doc_hdr-username = sy-uname. "User Name
g_tab_doc_hdr-comp_code = g_sav_bukrs.
g_tab_doc_hdr-doc_date = sy-datum. "Document Date in Document
g_tab_doc_hdr-pstng_date(04) = g_wrk_exp_h-bldat+4(04).
g_tab_doc_hdr-pstng_date+4(04) = g_wrk_exp_h-bldat(04).
g_tab_doc_hdr-fisc_year = sy-datum(4).
g_tab_doc_hdr-header_txt = g_wrk_exp_h-bktxt. "Document Header Text
g_tab_doc_hdr-doc_type = 'SA'. "Document type
g_tab_doc_hdr-reason_rev = g_wrk_exp_h-stgrd. "Reason for Reversal
IF g_wrk_exp_h-blart_sa EQ 'SA' OR g_wrk_exp_h-blart_sa EQ 'ZI'.
g_tab_doc_hdr-doc_type = g_wrk_exp_h-blart_sa.
ELSE.
g_tab_doc_hdr-doc_type = g_wrk_exp_h-blart_za.
ENDIF.
g_tab_doc_hdr-obj_key = ''. "'010000125910002007'."Object Key
g_tab_doc_hdr-obj_sys = sy-host. "Logical System of source doc.
g_tab_doc_hdr-OBJ_KEY_R = "Cancel: object key (AWREF_REV and AWORG_REV)
g_tab_doc_hdr-AC_DOC_NO = "Accounting Document Number
g_tab_doc_hdr-TRANS_DATE = "Translation date
g_tab_doc_hdr-fis_period = sy-datum+4(2). "Fiscal period
g_tab_doc_hdr-REF_DOC_NO = "Reference Document Number
g_tab_doc_hdr-COMPO_ACC = "Component in ACC Interface
g_tab_doc_hdr-REF_DOC_NO_LONG = "Reference Document Number (for Dependencies see Long Text)
g_tab_doc_hdr-ACC_PRINCIPLE = "Accounting Principle
APPEND g_tab_doc_hdr TO g_tab_doc_hdr.
CALL FUNCTION 'BAPI_ACC_GL_POSTING_CHECK'
EXPORTING
documentheader = g_tab_doc_hdr
TABLES
accountgl = g_tab_account_gl
currencyamount = g_tab_currency_amount
return = g_tab_return.
IF NOT g_tab_return IS INITIAL.
WRITE:/ 'BAPI_ACC_GL_POSTING_CHECK return messages.'.
LOOP AT g_tab_return.
WRITE:/ g_tab_return-number, '|',
g_tab_return-message(80).
ENDLOOP.
SKIP 1.
ENDIF.
IF g_tab_return IS INITIAL.
CALL FUNCTION 'BAPI_ACC_GL_POSTING_POST'
EXPORTING
documentheader = g_tab_doc_hdr
IMPORTING
obj_type = g_tab_obj_type "AWTYP
obj_key = g_tab_obj_key "AWKEY
obj_sys = g_tab_obj_sys "AWSYS
TABLES
accountgl = g_tab_account_gl
currencyamount = g_tab_currency_amount
return = g_tab_return
extension1 = g_tab_extension.
IF sy-subrc = 0.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = ' '
IMPORTING
return = g_commit_return.
ENDIF.
IF sy-subrc = 0.
IF NOT g_tab_return IS INITIAL.
WRITE:/ 'BAPI_ACC_GL_POSTING_POST return messages.'.
LOOP AT g_tab_return.
WRITE:/ g_tab_return-number, '|',
g_tab_return-message(80).
ENDLOOP.
SKIP 1.
ENDIF.
ENDIF.
ENDIF.
-
I apolygize for the length of this message, but thought it best to include code 'as is'.
Any guidance would be very much appreciated. I have reviewed other posting for FBs1, FB01 and F-02 BAPI's, which have really been helpful, but now I seem to be stuck on this error condition.
g_tab_doc_hdr data - one entry
BFISHER May Recon Open Items Adj
g_tab_account_gl data - two entrys
0000000001 8432200 1000 07/05/2007 SA 2007 11
80000 0000000000 0000
0000000002 8432900 1000 07/05/2007 SA 2007 11
80000 0000000000 0000
g_tab_currency_amount - two entrys
item_acc curr_type currency currency_iso amt_doccur exch_rate exch_rate_v
0000000001 00 USD 1,326.6400 0.00000 -
0000000002 00 USD 1,326.6400- 0.00000 -
Thanks,
Bill Fisher