‎2006 Feb 02 1:23 PM
Hi Friends,
Inside a user-exit I have to create a document.First of all is it possible to post document inside an exit ? If possible then here is my requirement.
A document with the following debit/credit details has to be created in BSEG or BSIS.
H(Cr) 101002(G/l acc) 20141434(Doc number) 20(Amt/dmbtr)
S(Dr) 822001(G/l) 20141434(Doc No) 20(Amt/dmbtr)
What function module should I use to create above document in BSEG or BSIS table ?
I have tried with BAPI_ACC_DOCUMENT_POST and BAPI_ACC_DOCUMENT_POST. But of no use.
Please advise me how to post this document inside the exit EXIT_RFEBBU10_001.
thanks for any help.
Vinod.
‎2006 Feb 02 1:36 PM
Hi
If you have to create an account document you have three way:
- Create BDC program for trx FB01;
- Use batchinput standard RFBIBL00;
- Use the BAPI BAPI_ACC_DOCUMENT_POST;
Now the problem is where you want to create the document, if you insert the creation into exit you should make sure your process is ran succesfully.
Max
‎2006 Feb 07 7:05 AM
Hi Max,
Thanks for the valuable suggestion. I could post the document successfully inside the exit with the bapi_acc_document_post.
Thanks
Vinod.
‎2006 Feb 07 7:25 AM
Hi Vinod,
I also wanted to post the FI Transaction by using
the same bapi
Could u send a sample program for the same BAPI
Regards
Ganesh
‎2006 Feb 07 12:29 PM
Hi Ganesh,
Please find the following code which I used.
Thanks
Vinod.
data: v_dmbtr like bsis-dmbtr,
v_kfmod(10),
v_amt like bsis-dmbtr,
febep_amt like bsis-dmbtr,
bseg_amt like bsis-dmbtr,
ws_documentheader like bapiache09,
it_accountgl like table of bapiacgl09 with header line,
it_currencyamount like table of bapiaccr09 with header line,
it_return like table of bapiret2 with header line,
commit_ret like table of bapiret2 with header line,
l_type like ws_documentheader-obj_type,
l_key like ws_documentheader-obj_key,
l_sys like ws_documentheader-obj_sys.
if i_febep-vgint eq 'Y699'.
unpack i_febep-kfmod to v_kfmod.
select single dmbtr from bsis into v_dmbtr where
bukrs eq i_febko-bukrs and hkont eq v_kfmod
and belnr eq i_febep-zuonr.
if sy-subrc eq 0.
v_amt = abs( i_febep-kwbtr - v_dmbtr ).
if i_febep-kwbtr > v_dmbtr.
febep_amt = -1 * v_amt.
bseg_amt = v_amt.
elseif v_dmbtr > i_febep-kwbtr.
bseg_amt = -1 * v_amt.
febep_amt = v_amt.
endif.
endif.
if v_amt ne space.
posting code
filling header
clear ws_documentheader.
ws_documentheader-bus_act = 'RFBU'.
ws_documentheader-username = sy-uname.
ws_documentheader-header_txt = 'BAPI Test'.
ws_documentheader-comp_code = i_febko-bukrs.
ws_documentheader-doc_date = sy-datum.
ws_documentheader-pstng_date = sy-datum.
ws_documentheader-fisc_year = '2006'.
ws_documentheader-doc_type = 'ZB'.
filling GL A/c
clear it_accountgl.
it_accountgl-itemno_acc = 1.
it_accountgl-gl_account = '0000822000'.
it_accountgl-doc_type = 'ZB'.
it_accountgl-comp_code = i_febko-bukrs.
it_accountgl-pstng_date = sy-datum.
it_accountgl-value_date = sy-datum.
append it_accountgl.
clear it_accountgl.
it_accountgl-itemno_acc = 2.
it_accountgl-gl_account = v_kfmod.
it_accountgl-gl_account = '0000101002'.
it_accountgl-doc_type = 'ZB'.
it_accountgl-comp_code = i_febko-bukrs.
it_accountgl-pstng_date = sy-datum.
it_accountgl-value_date = sy-datum.
append it_accountgl.
fillilng Currency amt
clear it_currencyamount.
it_currencyamount-itemno_acc = 1.
*it_currencyamount-curr_type = '10'.
it_currencyamount-currency = i_febep-kwaer.
it_currencyamount-amt_doccur = febep_amt.
it_currencyamount-amt_base = '0.0000'.
it_currencyamount-disc_base = '0.0000'.
it_currencyamount-disc_amt = '0.0000'.
append it_currencyamount.
clear it_currencyamount.
it_currencyamount-itemno_acc = 2.
*it_currencyamount-curr_type = '10'.
it_currencyamount-currency = i_febep-kwaer.
it_currencyamount-amt_doccur = bseg_amt.
it_currencyamount-amt_base = '0.0000'.
it_currencyamount-disc_base = '0.0000'.
it_currencyamount-disc_amt = '0.0000'.
append it_currencyamount.
*calling bapi
call function 'BAPI_ACC_DOCUMENT_POST'
exporting
documentheader = ws_documentheader
importing
obj_type = l_type
obj_key = l_key
obj_sys = l_sys
tables
accountgl = it_accountgl
currencyamount = it_currencyamount
return = it_return.
read table it_return with key type = 'S'.
if sy-subrc = 0.
clear commit_ret.
refresh commit_ret.
call function 'BAPI_TRANSACTION_COMMIT'
exporting
wait = 'X'
importing
return = commit_ret.
endif.
endif.
endif.
‎2006 Feb 02 2:59 PM
I really don't know if you can do this from within an exit, but you might look at BAPI_ACC_GL_POSTING_POST instead.
Rob