‎2008 Jan 15 11:26 AM
Hi experts,
I am using BAPI 'BAPI_ACC_DOCUMENT_POST' for G/L accounts posting ( TCODE: FB01L).
I have a requirement to update a field "Comp. ID of Trading partner" at line items level.
For that I am assigning a value for TRADE_ID ( Comp. ID of Trading partner) field in AccountGL table of BAPI.
But BAPI returns an error for any company code i assign to trade_id, the same company codes are working when i enter the data through transaction FB01L .
Please suggest what may be the problem or if there is any alternate way of achieving this
Thanks in advance
regards,
Gaurav
‎2008 Jan 15 11:37 AM
report z_test_bapi_gl_ac_doc .
data:
obj_type like bapiache02-obj_type,
obj_key like bapiache02-obj_key,
obj_sys like bapiache02-obj_sys,
documentheader like bapiache08,
accountgl like bapiacgl08
occurs 0 with header line,
currencyamount like bapiaccr08
occurs 0 with header line,
return like bapiret2
occurs 0 with header line,
extension1 like bapiextc
occurs 0 with header line,
t_edidd like edidd occurs 0 with header line,
bapi_retn_info like bapiret2 occurs 0 with header line.
data: error_flag.
documentheader-username = sy-uname.
documentheader-header_txt = 'Test using BAPI'.
documentheader-comp_code = '1000'.
documentheader-doc_date = sy-datum.
documentheader-pstng_date = sy-datum.
documentheader-doc_type = 'SA'.
accountgl-itemno_acc = '1'.
accountgl-gl_account = '0000160100'.
accountgl-comp_code = '1000'.
accountgl-pstng_date = sy-datum.
accountgl-doc_type = 'SA'.
accountgl-profit_ctr = '0000010000'.
append accountgl.
accountgl-itemno_acc = '2'.
accountgl-gl_account = '0000160100'.
accountgl-comp_code = '1000'.
accountgl-pstng_date = sy-datum.
accountgl-doc_type = 'SA'.
accountgl-profit_ctr = '0000010000'.
append accountgl.
currencyamount-itemno_acc = '1'.
currencyamount-currency = 'GBP'.
currencyamount-amt_doccur = '100.00'.
append currencyamount.
currencyamount-itemno_acc = '2'.
currencyamount-currency = 'GBP'.
currencyamount-amt_doccur = '-100.00'.
append currencyamount.
call BAPI-function in this system *
call function 'BAPI_ACC_GL_POSTING_POST'
exporting
documentheader = documentheader
importing
obj_type = obj_type
obj_key = obj_key
obj_sys = obj_sys
tables
accountgl = accountgl
currencyamount = currencyamount
return = return
extension1 = extension1
exceptions
others = 1.
if sy-subrc <> 0.
message e999(re) with 'Problem occured'.
else.
loop at return.
if not return is initial.
clear bapi_retn_info.
move-corresponding return to bapi_retn_info.
if return-type = 'A' or return-type = 'E'.
error_flag = 'X'.
endif.
append bapi_retn_info.
endif.
endloop.
if error_flag = 'X'.
message e999(re) with 'Problem occured'.
rollback work.
else.
commit work.
endif.
endif.
‎2008 Apr 08 7:17 AM
Hi Gaurav,
the field you are filling is wrong. You have to pass the trading partner id with the additional table extension, field name is vbund. See note 487722 how to build up the extension table. Reward if helpful.
Regards
Egon