Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Posting Tax entry through BAPI_ACC_DOCUMENT_POST

Former Member
0 Likes
686

Hi,

I want to post an invoice in FI with tax entry. The line items are:

900 Dr.

100 Dr. (Tax amount)

To 10000 Cr.

Here, I want tax amount to be posted in different G/L a/c's. When I am trying to post this entry through BAPI 'BAPI_ACC_DOCUMENT_POST' it is posting Tax amount to only one G/L a/c. If I try to post the same through FB01, it is working fine.

Please let me know how to post a tax entry through 'BAPI_ACC_DOCUMENT_POST' to different G/L a/c's.

2 REPLIES 2
Read only

Former Member
0 Likes
440

Hi,

Try this piece of code

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.

for multiple g/l you will have to append the tables for multiple g/l means create more items ie add more items to this tables accountgl,

Hope it helps.

Regards

Hiren K.Chitalia

Edited by: Hiren Chitalia on Jul 31, 2009 11:01 AM

Read only

Former Member
0 Likes
440

Thanks Hiren for your response.

But my problem is I am uploading the data through this BAPI. Since uplaoded file will not contain this information, I cannot pass different G/l a/c's to this BAPI

Is it possible to post the tax amount to three different G.l a/c's without passing the g/l a/c to BAPI? Since this is possible manually through FB01.