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

BAPI_ACC_DOCUMENT_POST calculate tax.

SwadhinGhatuary
Active Contributor
0 Likes
7,872

how to fill respective table for calculate tax in BAPI_ACC_DOCUMENT_POST .i fill in accounttax table but i get error tax code does not exist even though the same is existing.After debugging i found entry is not maintained in a003 table . Please suggest how to calculate tax in bapi  BAPI_ACC_DOCUMENT_POST.

Thanks for your Reply.

But i have calculate tax, not coding found for that ..

Please suggest me what to do?

6 REPLIES 6
Read only

Mohamed_Mukhtar
Active Contributor
0 Likes
4,068

Hello Swadhin,

Use FM CALCULATE_TAX_FROM_GROSSAMOUNT to calculate taxes and pass it to the tax table of bapi.



Thanks

Read only

0 Likes
4,068

Dear Swadhin

this code is working, just adjust it with your parameters:

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 = 'IS'.

accountgl-itemno_acc = '1'.

accountgl-gl_account = '2600100001' .

accountgl-comp_code = '1000'.

accountgl-pstng_date = sy-datum.

accountgl-doc_type = 'IS'.

*accountgl-profit_ctr = '0000010000'.

append accountgl.

accountgl-itemno_acc = '2'.

accountgl-gl_account ='2600100001' .

accountgl-comp_code = '1000'.

accountgl-pstng_date = sy-datum.

accountgl-doc_type = 'IS'.

*accountgl-profit_ctr = '0000010000'.

append accountgl.

currencyamount-itemno_acc = '1'.

currencyamount-currency = 'TRY'.

currencyamount-amt_doccur = '100.00'.

append currencyamount.

currencyamount-itemno_acc = '2'.

currencyamount-currency = 'TRY'.

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.

Read only

0 Likes
4,068

Thanks For your Reply.

I have already calculated tax by using that function module but at the time of filling accounttax table and execute error trigger tax code  not found.

please suggest what to fill in that

Read only

0 Likes
4,068

Thanks for your Reply.

But i have calculate tax, not coding found for that ..

Please suggest me what to do?

Read only

0 Likes
4,068

Hello Swadhin,

Please check with your functional consultant why the taxcode is not defined.

Thanks

Read only

Former Member
0 Likes
4,068

Hi  Swadhin,

See if you are passing values like below or not.

* gl-line expense item related data

accountgl-itemno_acc = '20'.

accountgl-gl_account = '0000510020'.

accountgl-tax_code   = 'U1'.

accountgl-taxjurcode = '0508525201'.

accountgl-costcenter      = 'US01'.

accountgl-bus_area        = '0001'.

currencyamount-itemno_acc = '20'.

currencyamount-curr_type  = '00'.

currencyamount-currency   = 'USD'.

currencyamount-amt_doccur = '109.00'.

*currencyamount-amt_doccur = '108.25'. "would be correct

APPEND accountgl.

APPEND currencyamount.

*-----------------------------------------------------

*NVV tax line items (Non deductible tax)

CLEAR accounttax.

CLEAR currencyamount.

accounttax-itemno_acc = '30'.

accounttax-tax_code   = 'U1'.

accounttax-acct_key   = 'NVV'.

accounttax-cond_key   = 'XP1I'.

accounttax-tax_rate   = '6.00'.

accounttax-taxjurcode = '0500000000'.

accounttax-taxjurcode_deep = '0508525201'.

accounttax-taxjurcode_level = '1'.

*----------------------------------------------------

* tax line item refers to accountgl-itemno_acc = '20'

* which will be line item bseg-buzei = '002' in the final document

accounttax-itemno_tax =  '002'.

*----------------------------------------------------

*accounttax-stat_con   = 'X'.

currencyamount-itemno_acc = '30'.

currencyamount-curr_type  = '00'.

currencyamount-currency   = 'USD'.

currencyamount-amt_doccur = '6'.

currencyamount-amt_base   = '100'.

APPEND accounttax.

APPEND currencyamount.

CLEAR accounttax.

CLEAR currencyamount.

accounttax-itemno_acc = '40'.

accounttax-tax_code   = 'U1'.

accounttax-acct_key   = 'NVV'.

accounttax-cond_key   = 'XP2I'.

accounttax-tax_rate   = '1.25'.

accounttax-taxjurcode = '0508500000'.

accounttax-taxjurcode_deep = '0508525201'.

accounttax-taxjurcode_level = '2'.

accounttax-itemno_tax =  '002'.

* accounttax-stat_con   = 'X'.

currencyamount-itemno_acc = '40'.

currencyamount-curr_type  = '00'.

currencyamount-currency   = 'USD'.

currencyamount-amt_doccur = '2'.

*currencyamount-amt_doccur = '1.25'. "Would be correct

currencyamount-amt_base   = '100'.

APPEND accounttax.

APPEND currencyamount.

Regards,

Rafi