on 05-12-2006 2:54 PM
Hi,
I am trying to park the document using FM BAPI_ACC_DOCUMENT_POST or FM BAPI_ACC_GL_POSTING_POST.
Here I am making use of the BADI ACC_DOCUMENT to pass the value '2' to C_ACCHD-STATUS_NEW ( C_ACCHD-STATUS_NEW = '2') by which it should actually park the document.The process is successfull where i am getting the message like "document posted successfully " and document number generated but I could not see the document through FBV1 or FB01. Can anyone please through some light on this. Thanks in Advance.
Hi Sarath,
I have done this let me tell you the approach.
Step 1: you should implement the BTE RWBAPI01.
Step 2: Pass value '2' to DOCUMENT_HEADER-STATUS_NEW of the changing parameter of BTE. Now the document will get parked successfully. Please find the sample code.
TABLES: bsik.
DATA: w_doc_header TYPE bapiache09,
t_accountreceivable TYPE TABLE OF bapiacar09,
w_accountreceivable TYPE bapiacar09,
t_accountpayable TYPE TABLE OF bapiacap09,
w_accountpayable TYPE bapiacap09,
t_accounttax TYPE TABLE OF bapiactx09,
w_accounttax TYPE bapiactx09,
t_currencyamount TYPE TABLE OF bapiaccr09,
w_currencyamount TYPE bapiaccr09,
t_extension2 TYPE TABLE OF bapiparex,
w_extension2 TYPE bapiparex,
t_extension1 TYPE TABLE OF bapiacextc,
w_extension1 TYPE bapiacextc,
t_accountgl TYPE TABLE OF bapiacgl09,
w_accountgl TYPE bapiacgl09,
w_accountgl_1 TYPE bapiacgl09,
t_return TYPE TABLE OF bapiret2,
w_lineitems TYPE zst_vendor_items,
w_return TYPE bapiret2,
l_amount TYPE char18,
t_bsik TYPE TABLE OF bsik,
w_bsik TYPE bsik,
l_dmbtrp TYPE bapidmbtr,
* l_result TYPE bapidmbtr,
l_dmbtrn TYPE bapidmbtr,
l_result TYPE bapidmbtr,
lv_type TYPE bapiache09-obj_type,
lv_key TYPE bapiache09-obj_key,
lv_sys TYPE bapiache09-obj_sys,
l_fiyrs TYPE budat,
l_fiyrt TYPE allgstid,
l_index TYPE sy-index,
l_belnr TYPE belnr_d,
l_datum TYPE bapi3007-key_date,
l_message TYPE char20,
l_postingdate TYPE budat,
l_docdate TYPE budat,
l_glacno TYPE hkont,
lv_pos TYPE posnr_acc,
l_lifnr TYPE lifnr VALUE '10089',
l_counter TYPE posnr_acc VALUE '0000000001',
l_costcenter TYPE kostl,
l_date TYPE char2,
l_month TYPE char2,
l_year TYPE char4.
*---Fill GL details-----*
CLEAR: w_accountgl,w_doc_header,w_accountpayable,
w_currencyamount, l_dmbtrp,l_dmbtrn,lv_type,lv_key,lv_sys,
e_message,w_lineitems,l_year,l_month,l_date.
REFRESH: t_accountgl[],t_accountpayable[],t_currencyamount[],
t_extension1[],t_return[].
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = i_vendor
IMPORTING
output = l_lifnr.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = w_lineitems-glacno
IMPORTING
output = l_glacno.
SPLIT i_postingdate AT '-' INTO l_year l_month l_date.
CONCATENATE l_year l_month l_date INTO l_postingdate.
* l_postingdate = i_postingdate.
CLEAR: l_year,l_month,l_date.
SPLIT i_docdate AT '-' INTO l_year l_month l_date.
CONCATENATE l_year l_month l_date INTO l_docdate.
* l_docdate = i_docdate.
*---Fill Header details-----*
w_doc_header-bus_act = 'RFBU'."'RMRP'.
w_doc_header-obj_type = 'BKPFF'."'REACI'."'VBRK'.
w_doc_header-obj_key = '$'.
w_doc_header-obj_sys = 'T90CLNT090'.
w_doc_header-username = sy-uname.
w_doc_header-header_txt = i_hdrtext."'Vendor Invoice '.
w_doc_header-comp_code = i_compcode."'3000'."p_bukrs.
w_doc_header-doc_date = l_docdate.
w_doc_header-pstng_date = l_postingdate." l_postingdate.
w_doc_header-doc_type = i_doctype."'KR'.
w_doc_header-ref_doc_no = i_reference."'KR'.
*---Fill Vendor details---------*
w_accountpayable-itemno_acc = '0000000001'.
w_accountpayable-vendor_no = l_lifnr.
w_accountpayable-comp_code = i_compcode."'3000'."p_bukrs.
w_accountpayable-pymt_meth = i_payment_method."'T'.
w_accountpayable-pmnttrms = '0002'.
APPEND w_accountpayable TO t_accountpayable.
*------Segregating Positive and Negative Amounts---------------------*
w_currencyamount-itemno_acc = '0000000001'. " gl accou +ve 40
w_currencyamount-currency_iso = i_currency."'USD'.
w_currencyamount-amt_doccur = i_amount * -1."500.
APPEND w_currencyamount TO t_currencyamount.
w_extension1-field1 = '000000000131'. "gl psokey
APPEND w_extension1 TO t_extension1.
LOOP AT t_lineitems INTO w_lineitems.
CLEAR: w_accountgl,w_accountgl_1,l_costcenter.
l_counter = l_counter + 1.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = w_lineitems-glacno
IMPORTING
output = l_glacno.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = w_lineitems-costcenter
IMPORTING
output = l_costcenter.
w_accountgl-itemno_acc = l_counter."'0000000001'.
w_accountgl-gl_account = l_glacno."'0000113100'.
w_accountgl-item_text = i_hdrtext."'Test'.
w_accountgl-comp_code = i_compcode."'3000'."p_bukrs.
w_accountgl-value_date = l_postingdate.
w_accountgl-pstng_date = l_postingdate.
w_accountgl-doc_type = i_doctype."'KR'.
w_accountgl-segment = w_lineitems-segment."'SERV'.
w_accountgl-partner_segment = w_lineitems-partnerseg.
w_accountgl-cs_trans_t = w_lineitems-transtype.
w_accountgl-costcenter = l_costcenter."'0000000328'.
w_accountgl-fis_period = l_postingdate+4(2).
w_accountgl-fisc_year = l_postingdate+0(4).
APPEND w_accountgl TO t_accountgl.
IF w_lineitems-credit = 'H'.
w_currencyamount-itemno_acc = l_counter."'0000000002'.
w_currencyamount-currency_iso = i_currency."'USD'.
w_currencyamount-amt_doccur = -1 * w_lineitems-amount. "500. " vendor -ve 31
APPEND w_currencyamount TO t_currencyamount.
CONCATENATE l_counter '50' INTO w_extension1-field1 .
APPEND w_extension1 TO t_extension1.
ELSE.
w_currencyamount-itemno_acc = l_counter."'0000000002'.
w_currencyamount-currency_iso = i_currency."'USD'.
w_currencyamount-amt_doccur = 1 * w_lineitems-amount. "500. " vendor -ve 31
APPEND w_currencyamount TO t_currencyamount.
CONCATENATE l_counter '40' INTO w_extension1-field1 .
APPEND w_extension1 TO t_extension1.
ENDIF.
CLEAR : w_currencyamount,w_lineitems,w_accountgl.
ENDLOOP.
* w_extension1-field1 = 'PARK' .
* APPEND w_extension1 TO t_extension1.
CALL FUNCTION 'BAPI_ACC_DOCUMENT_CHECK'
EXPORTING
documentheader = w_doc_header
TABLES
accountgl = t_accountgl
accountpayable = t_accountpayable
currencyamount = t_currencyamount
extension1 = t_extension1
return = t_return.
REFRESH: t_return[].
CALL FUNCTION 'BAPI_ACC_DOCUMENT_POST'
EXPORTING
documentheader = w_doc_header
IMPORTING
obj_type = lv_type
obj_key = lv_key
obj_sys = lv_sys
TABLES
accountgl = t_accountgl
accountpayable = t_accountpayable
currencyamount = t_currencyamount
extension1 = t_extension1
return = t_return.
READ TABLE t_return INTO w_return WITH KEY type = 'E'.
IF sy-subrc <> 0.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
CLEAR: l_message.
CONCATENATE 'Vendor Invoice' lv_key+0(10) 'Created' INTO e_message
SEPARATED BY ''.
ELSE.
READ TABLE t_return INTO w_return INDEX 2.
e_message = w_return-message.
ENDIF.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello All
I have met the same problem.
I found it is impossible to park a FI document directly by the bapi 'BAPI_ACC_DOCUMENT_POST' .
BDC is a solution to it .
But I have to park a plent of document at one time , BDC is too slow. Finally I found the function 'PRELIMINARY_POSTING_DOC_WRITE' . You can use it to park a document.Hope it can be helpful.But it takes a risk of making unkown errors.
Here is my sample code:
REPORT z_test.
DATA: lt_acc_gl TYPE TABLE OF bapiacgl09 ,
lt_acc_ap TYPE TABLE OF bapiacap09 ,
lt_acc_ar TYPE TABLE OF bapiacar09 ,
lt_return TYPE TABLE OF bapiret2 ,
lt_curr_amt TYPE TABLE OF bapiaccr09 ,
lt_doc_header TYPE TABLE OF bapiache09 ,
lt_acc_tax TYPE TABLE OF bapiactx09 ,
lt_criteria TYPE TABLE OF bapiackec9 ,
ld_obj_type LIKE bapiache09-obj_type,
ld_obj_key LIKE bapiache09-obj_key,
ld_obj_sys LIKE bapiache09-obj_sys,
ld_tax_code TYPE mwskz,
ld_posnr TYPE posnr_acc,
ld_rate TYPE kbetr_kond.
DATA: ls_doc_header TYPE bapiache09,
ls_acc_ap TYPE bapiacap09,
ls_curr_amt TYPE bapiaccr09,
ls_acc_gl TYPE bapiacgl09,
ls_acc_ar TYPE bapiacar09,
ls_acc_tax TYPE bapiactx09,
ls_criteria TYPE bapiackec9.
*HEAD
CLEAR ls_doc_header.
ls_doc_header-bus_act = 'RFBU'.
ls_doc_header-username = sy-uname.
ls_doc_header-header_txt = 'Created by Bapi'. " Invoice Text
ls_doc_header-comp_code = '7300'. " Company Code
ls_doc_header-doc_date = sy-datum . " Invoice Date
ls_doc_header-pstng_date = sy-datum. " Posting Date
ls_doc_header-doc_type = 'DI'.
ls_doc_header-ref_doc_no = 'REFERENCE DOC NO.'.
APPEND ls_doc_header TO lt_doc_header.
*GL
CLEAR:lt_acc_gl,ls_acc_gl,lt_curr_amt.
ls_acc_gl-itemno_acc = '0000000001'.
ls_acc_gl-gl_account = '54050300'. " GL Account
UNPACK ls_acc_gl-gl_account TO ls_acc_gl-gl_account.
ls_acc_gl-doc_type = 'DI'. " Doc Type
ls_acc_gl-comp_code = '7300'. " Company Code
ls_acc_gl-pstng_date = sy-datum. " Posting Date
ls_acc_gl-de_cre_ind = 'H'. " Credit
ls_acc_gl-profit_ctr = 'ACRT1101'.
APPEND ls_acc_gl TO lt_acc_gl.
CLEAR ls_curr_amt.
ls_curr_amt-itemno_acc = '0000000001'. " Invoice Number
ls_curr_amt-curr_type = '00'.
ls_curr_amt-currency = 'HKD'. " Currency
ls_curr_amt-amt_doccur = - 100 . " Line Item Amount
ls_curr_amt-disc_base = - 100 .
APPEND ls_curr_amt TO lt_curr_amt.
*CUSTOMER
CLEAR: ls_acc_ar,lt_acc_ar.
ls_acc_ar-comp_code = '7300'.
ls_acc_ar-tax_code = '**'."sales tax
ls_acc_ar-item_text = ''.
ls_acc_ar-customer = '0007312345'.
ls_acc_ar-itemno_acc = '0000000002'.
APPEND ls_acc_ar TO lt_acc_ar.
CLEAR ls_curr_amt.
ls_curr_amt-itemno_acc = '0000000002'. " Invoice Number
ls_curr_amt-curr_type = '00'.
ls_curr_amt-currency = 'HKD'. " Currency
ls_curr_amt-amt_doccur = 100 . " Line Item Amount
ls_curr_amt-disc_base = 100 .
APPEND ls_curr_amt TO lt_curr_amt.
CLEAR ls_criteria.
ls_criteria-itemno_acc = '0000000001'.
ls_criteria-fieldname = 'WWICF'.
ls_criteria-character = 'TP'.
APPEND ls_criteria TO lt_criteria.
CALL FUNCTION 'BAPI_ACC_DOCUMENT_POST'
EXPORTING
documentheader = ls_doc_header
IMPORTING
obj_type = ld_obj_type
obj_key = ld_obj_key
obj_sys = ld_obj_sys
TABLES
accountgl = lt_acc_gl
currencyamount = lt_curr_amt
accountpayable = lt_acc_ap
accountreceivable = lt_acc_ar
criteria = lt_criteria
return = lt_return.
CHECK sy-subrc = 0.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X'.
UPDATE bkpf SET bstat = 'V'
ausbk = ld_obj_key+10(4)
WHERE bukrs = ld_obj_key+10(4)
AND belnr = ld_obj_key(10)
AND gjahr = ld_obj_key+14(4).
DATA : ls_uf05a TYPE uf05a,
ld_bstat TYPE char1.
DATA: BEGIN OF xvbkpf OCCURS 20 .
INCLUDE STRUCTURE fvbkpf.
DATA: END OF xvbkpf.
DATA: BEGIN OF xvbsec OCCURS 20 .
INCLUDE STRUCTURE fvbsec.
DATA: END OF xvbsec.
DATA: BEGIN OF xvbseg OCCURS 20.
INCLUDE STRUCTURE fvbseg.
DATA: END OF xvbseg.
DATA: xvacsplt TYPE vacsplt OCCURS 0 WITH HEADER LINE.
DATA: xvspltwt TYPE vspltwt OCCURS 0 WITH HEADER LINE.
DATA: BEGIN OF xvbset OCCURS 20.
INCLUDE STRUCTURE fvbset.
DATA: END OF xvbset.
TABLES:bkpf,vbkpf,bseg,vbsegd,vbsegs.
SELECT SINGLE * FROM bkpf WHERE bukrs = ld_obj_key+10(4)
AND belnr = ld_obj_key(10)
AND gjahr = ld_obj_key+14(4).
CHECK sy-subrc = 0.
MOVE-CORRESPONDING bkpf TO xvbkpf.
xvbkpf-awtyp = 'BKPF'.
APPEND xvbkpf .
SELECT * FROM bseg WHERE bukrs = ld_obj_key+10(4)
AND belnr = ld_obj_key(10)
AND gjahr = ld_obj_key+14(4).
MOVE-CORRESPONDING bseg TO xvbsec.
xvbsec-ausbk = ld_obj_key+10(4).
APPEND xvbsec.
ENDSELECT.
SELECT * FROM bseg WHERE bukrs = ld_obj_key+10(4)
AND belnr = ld_obj_key(10)
AND gjahr = ld_obj_key+14(4).
MOVE-CORRESPONDING bseg TO xvbseg.
xvbseg-ausbk = ld_obj_key+10(4).
IF xvbseg-saknr IS INITIAL.
xvbseg-saknr = xvbseg-hkont.
ENDIF.
APPEND xvbseg.
ENDSELECT.
SELECT SINGLE * FROM bkpf WHERE bukrs = ld_obj_key+10(4)
AND belnr = ld_obj_key(10)
AND gjahr = ld_obj_key+14(4).
CHECK sy-subrc = 0.
*MOVE-CORRESPONDING bkpf TO vbkpf.
*vbkpf-awtyp = 'BKPF'.
*INSERT vbkpf .
DELETE bkpf.
*SELECT * FROM bseg WHERE bukrs = ld_obj_key+10(4)
AND belnr = ld_obj_key(10)
AND gjahr = ld_obj_key+14(4).
MOVE-CORRESPONDING bseg TO vbsegd.
vbsegd-ausbk = ld_obj_key+10(4).
INSERT vbsegd.
*ENDSELECT.
CALL FUNCTION 'PRELIMINARY_POSTING_DOC_WRITE'
EXPORTING
i_uf05a = ls_uf05a
i_bstat = ld_bstat
TABLES
t_vbkpf = xvbkpf
t_vbsec = xvbsec
t_vbseg = xvbseg
t_vacsplt = xvacsplt "Note481737
t_vspltwt = xvspltwt "Note481737
t_vbset = xvbset.
CHECK sy-subrc = 0.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
You can't park the document using BAPI_ACC_GL_POSTING_POST
Bapi.There is no Bapi available for parking the document.Use BDC for parking the document.
thanks,
rakesh.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Sarath,
I am also having the same problem. We are calling the BAPI_ACC_DOCUMENT_POST and then BAPI_TRANSACTION_COMMIT. It says the document is successfully created, but the data is not in the tables (BKPF). We are also using badi ACC_DOCUMENT->CHANGE to change the C_ACCHD-STATUS_NEW = 3 in order to park the document.
If you found the solution to your issue, please let me know.
Thanks a lot.
Regards,
Salai.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Not sure, but is the number returned the document number or the reference key. Use SE16 to look in BKPF for documents created on the current day.
Michael
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hai Sarath
use the following Class 'CL_REEX_DOC_FI'
with method 'POST_EX'.
also check the SAP Program 'ACC_BAPI_TEST_DOCUMENT'.
CALL FUNCTION 'BAPI_ACC_DOCUMENT_POST'
EXPORTING
documentheader = gd_documentheader
customercpd = gd_customercpd
contractheader = gd_fica_hd
IMPORTING
obj_type = l_type
obj_key = l_key
obj_sys = l_sys
TABLES
accountgl = it_accountgl
accountreceivable = it_accountreceivable
accountpayable = it_accountpayable
accounttax = it_accounttax
currencyamount = it_currencyamount
criteria = it_criteria
valuefield = it_valuefield
extension1 = it_ext
return = it_return
paymentcard = it_paymentcard
contractitem = it_fica_it
extension2 = it_ext2
realestate = it_re.
Thanks & Regards
Sreenivasulu P
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Sarath,
You need to commit work after calling bapi. All bapis need explicit commit work.
So commit work after calling bapi. Abap Stament is :
Commit work.
Or if you are executing bapi thru SE37, Goto -->
Function Module ->Test->Test Sequence
and put your bapi in first text box and 'BAPI_TRANSACTIOn_COMMIT' in next text box.
This will solve your problem.
Cheers,
Nilesh
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Sarath,
You need to commit work after calling bapi. All bapis need explicit commit work.
So commit work after calling bapi. Abap Stament is :
Commit work.
Or if you are executing bapi thru SE37, Goto -->
Function Module ->Test->Test Sequence
and put your bapi in first text box and 'BAPI_TRANSACTIOn_COMMIT' in next text box.
This will solve your problem.
Cheers,
Nilesh
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
FI BAPI's messages are deceiving, as it says "document #xxxxxxxx was successfully created" but actually not. In the FI BAPI, there is a code to check where you are running from. If you are running from SE37, it decides "test only", and will not actually update the database.
You need to create a simple ABAP test program to put the FI BAPI along with BAPI_TRANSACTION_COMMIT to update the database.
Hope this helps.
Noriko
User | Count |
---|---|
88 | |
10 | |
10 | |
9 | |
7 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.