‎2010 Jan 15 6:13 AM
Hi All,
I am using BAPI_ACC_DOCUMENT_POST for GL account postings (FB01) .
However , I am getting error when using the BAPI. If the posting key is 40 ( debit) , I maintain the amount as it is (positive) and if the posting key is 50 (credit) i change the amount to negative value and then do teh postings. But i get the following error in such a case. :
The +/- sign in the currency field is wrong (See Long text)
Below is the code :
ls_docheader-username = sy-uname.
ls_docheader-bus_act = 'RFBU'.
ls_docheader-doc_type = ls_record-blart.
ls_docheader-header_txt = ls_record-bktxt.
ls_docheader-comp_code = ls_record-bukrs.
ls_docheader-doc_date = ls_record-bldat.
ls_docheader-pstng_date = ls_record-budat.
ls_docheader-ref_doc_no = ls_record-xblnr.
ENDIF.
IF ls_record-bschl1 = '40'.
lv_count = lv_count + 1.
*Fill the bapi structure of Account GL
ls_accountgl-itemno_acc = lv_count.
ls_accountgl-gl_account = ls_record-hkont.
ls_accountgl-item_text = ls_record-sgtxt.
ls_accountgl-func_area = ls_record-fkber.
ls_accountgl-costcenter = ls_record-kostl.
ls_accountgl-profit_ctr = ls_record-prctr.
ls_accountgl-orderid = ls_record-aufnr.
APPEND ls_accountgl TO lt_accountgl.
CLEAR ls_accountgl.
*Fill the bapi structure of Currency
ls_amount-itemno_acc = lv_count.
ls_amount-currency = ls_record-waers.
ls_amount-exch_rate = ls_record-kursf.
ls_amount-amt_doccur = ls_record-wrbtr. -------> debit amount
APPEND ls_amount TO lt_amount.
CLEAR ls_amount.
ELSEIF ls_record-bschl1 = '50'.
* *Fill the bapi structure of Account GL
ls_accountgl-itemno_acc = lv_count.
ls_accountgl-gl_account = ls_record-hkont.
ls_accountgl-item_text = ls_record-sgtxt.
ls_accountgl-func_area = ls_record-fkber.
ls_accountgl-costcenter = ls_record-kostl.
ls_accountgl-profit_ctr = ls_record-prctr.
ls_accountgl-orderid = ls_record-aufnr.
APPEND ls_accountgl TO lt_accountgl.
CLEAR ls_accountgl.
*Fill the bapi structure of Currency
ls_amount-itemno_acc = lv_count.
ls_amount-currency = ls_record-waers.
ls_amount-exch_rate = ls_record-kursf.
ls_amount-amt_doccur = -1 * ls_record-wrbtr. -----> credit amount
APPEND ls_amount TO lt_amount.
CLEAR ls_amount.
ENDIF.
‎2010 Jan 15 7:38 AM
Hello Vasuki S Patki,
use the amounts without negative sign. The posting key 50 let the system know that this is a negative amount.
Regards
Dirk
‎2010 Jan 15 9:31 AM
You can use BAPI_ACC_GL_POSTING_POST to post the document through FB01 and below is the code
in the document header fill the below value
MOVE: p_bldat TO s_dochdr-doc_date,
p_blart TO s_dochdr-doc_type,
p_budat TO s_dochdr-pstng_date,
p_monat TO s_dochdr-fis_period,
s_gl_data2-newbk TO s_dochdr-comp_code,
p_xblnr TO s_dochdr-ref_doc_no,
p_bktxt TO s_dochdr-header_txt,
v_usnam TO s_dochdr-username,
v_fisc_year TO s_dochdr-fisc_year,
p_wwert TO s_dochdr-trans_date.
IF v_wrbtr > 0.
v_dummy_line = v_dummy_line + c_10.
s_accountgl-itemno_acc = v_dummy_line.
s_accountgl-gl_account = s_gl_data-saknr.
s_accountgl-comp_code = s_gl_data-newbk.
s_accountgl-pstng_date = p_budat.
s_accountgl-doc_type = p_blart.
s_accountgl-fisc_year = v_fisc_year.
s_accountgl-fis_period = p_monat.
s_accountgl-ref_key_1 = s_gl_data-xref1.
s_accountgl-ref_key_2 = s_gl_data-xref2.
s_accountgl-costcenter = s_gl_data-kostl.
s_accountgl-orderid = s_gl_data-aufnr.
s_accountgl-alloc_nmbr = s_gl_data-dzuonr.
s_accountgl-item_text = s_gl_data-sgtxt.
s_accountgl-profit_ctr = s_gl_data-prctr.
s_accountgl-wbs_element = s_gl_data-posid.
APPEND s_accountgl TO t_accountgl.
v_wrbtr = v_wrbtr * -1.
s_currencyamount-itemno_acc = v_dummy_line.
s_currencyamount-amt_doccur = v_wrbtr.
s_currencyamount-currency = p_waers.
APPEND s_currencyamount TO t_currencyamount.
ENDIF.
CALL FUNCTION 'BAPI_ACC_GL_POSTING_POST'
EXPORTING
documentheader = s_dochdr
TABLES
accountgl = t_accountgl
currencyamount = t_currencyamount
return = t_returnpost
extension1 = t_extension.