Application Development 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: 

How to pass Multiple Tax Rate to BAPI_ACC_DOCUMENT_POST

Mohamed_Mukhtar
Active Contributor
0 Kudos

Hello,

I'm using FM CALCULATE_TAX_FROM_GROSSAMOUNT to fetch tax rates based on tax jurisdiciton code , currency and amount.

After that collecting all relevant data in internal table and passing it to accounttax table in BAPI.

If we have single tax rate then BAPI_ACC_DOCUMENT_POST is successfully posting the docuemnt.

For a particular company code and tax code we have multiple tax rates. How can we pass multiple tax rates to bapi.

The error "Balance in transaction currency" i'm getting

Thanks

-Always Learner

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi Learner,

You should be doing as it is done when posted manually using FB01 / F-02 transactions. i.e If you have 2 line items normal and 2 line items are tax line items, check how it is posted in FB01 / F-02. Simulate it using the BAPI.

FYI - SAP allows 50 tax line items.

In BAPI, however, we may have to add it manually while it may happen automatically in FB01 / F-02.

Hope it helps.

Sujay

8 REPLIES 8

Former Member
0 Kudos

Hi Learner,

You should be doing as it is done when posted manually using FB01 / F-02 transactions. i.e If you have 2 line items normal and 2 line items are tax line items, check how it is posted in FB01 / F-02. Simulate it using the BAPI.

FYI - SAP allows 50 tax line items.

In BAPI, however, we may have to add it manually while it may happen automatically in FB01 / F-02.

Hope it helps.

Sujay

0 Kudos

Thanks Sujay...!!!

Yes, i'm adding tax rates manually. BAPI is successfully posting when there is only one tax rate for a tax code.

The issue is when a tax code has multiple tax rates. I'm fetching tax rates by passing taxcode, companycode,currency , tax jurisdiction code.

CALL FUNCTION 'CALCULATE_TAX_FROM_GROSSAMOUNT'
      EXPORTING
        i_bukrs                 = comp_code
        i_mwskz                 = ld_mwskz
        I_TXJCD                 = ld_txjcd
        i_waers                 = ld_waers
        i_wrbtr                 = ld_wrbtr
      TABLES
        t_mwdat                 = lt_mwdat
case sy-subrc.
When 0.
LOOP AT lt_mwdat INTO   ls_mwdat.
IF  NOT ls_mwdat-msatz IS INITIAL.
          ld_itemcounter = ld_itemcounter + 1 .
          ld_wrbtr = gs_sap_dtl_d_rec_icrrb-amount -
                     gs_sap_dtl_d_rec_icrrb-tax_amount.
          MOVE ld_itemcounter                    TO ls_currencyamount-itemno_acc.
          MOVE ld_waers                          TO ls_currencyamount-currency.
          MOVE gs_sap_dtl_d_rec_icrrb-tax_amount TO ls_currencyamount-amt_doccur.
          MOVE ld_wrbtr                          TO ls_currencyamount-amt_base.
          APPEND ls_currencyamount TO lt_currencyamount.
MOVE ld_itemcounter                    TO ls_accounttax-itemno_acc.
          MOVE ls_mwdat-kschl                    TO ls_accounttax-cond_key.
          MOVE ls_mwdat-ktosl                    TO ls_accounttax-acct_key.
          MOVE ls_mwdat-msatz                    TO ls_accounttax-tax_rate.
          MOVE ld_mwskz                          TO ls_accounttax-tax_code.
APPEND ls_accounttax TO lt_accounttax.
ENDLOOP.
endcase.

Please give me some hints to post document with multiple tax rates.

Thanks
-Always Learner

0 Kudos

Hi Learner,

Suppose you have 2 line items and 2 tax line items, 1 posting into GL account, 1 into customer account, 2 tax line item.

Then internal table ACCOUNTGL will have 1 line item, ACCOUNTRECEIVABLE will have 1 ine item, ACCOUNTTAX will have 2 line items.

currencyamount will have 4 line items ( 1 for each line item ). ( Give the line item correctly ).

Check if you are passing the line items correctly.

Also, Do you get error / the document gets posted?

Hope it helps.

Sujay

0 Kudos

Thanks again Sujay.....!

In my file i have two tax items . Here the problem is for one tax item i have two tax rates.

For example i have tax code as T1, tax jurisdiciton as ABCD and currency CAD, for this combination i have two tax rates TR11 and TR12. i,e for two tax items , now i have 4 tax rates. THese 4 tax rates need to be passed to BAPI.

Now i have to pass these 4 tax rates to account tax table. When there is one tax rate i'm able to post document.

When trying to post tax items with multiple tax rates its giving me error "Balance in transaction currency". By looking at the error message we can say that it is because of mismatch in credit and debit amount.

Thanks

-Always Learner

0 Kudos

Hi Learner

I am also experiencing the same issue. Will you please share, how you managed to solve this issue.

Your assistance will be greatly appreciated.

Kind Regards,

Dineo

0 Kudos

Hi Dieno,

Use the below FM to calculate taxes .

CALL FUNCTION 'CALCULATE_TAX_FROM_GROSSAMOUNT'

      EXPORTING

        i_bukrs                 = comp_code

        i_mwskz                 = ld_mwskz

        I_TXJCD                 = ld_txjcd

        i_waers                 = ld_waers

        i_wrbtr                 = ld_wrbtr

      TABLES

        t_mwdat                 = lt_mwdat

loop internal table lt_mwdat , fill internabl tables accounttax and currencyamount accordingly.

Pass it to BAPI.

Thanks

-Learner

0 Kudos

Hi Learner

Thanks for the prompt response but i am still facing the same issue. I have given brief examples below to further explain how I populated the AccountTax and CurrencyAmount tables.

I am using function module CALCULATE_TAX_FROM_GROSSAMOUNT, and then looping into lt_mwdat to update the tables.

For example:

Accounttax table will have 2 entries (Being the tax rates from the tax code given i.e. T1)

Currencyamount table will then have 4 entries:

First entry:           AMT_DOCCUR = gross amount - tax amounts      e.g. 100

Second entry:      AMT_DOCCUR = balancing amount                      e.g. -250

Third entry:          AMT_DOCCUR = Amount of one of the tax rates:  e.g. 50

Fourth entry:        AMT_DOCCUR = Amount of the second tax rate:  e.g. 100

AMT_BASE field for the third and fourth entry is then 100 (Gross amount - tax amounts) but I am still getting the same error.  And when the tax code only has one tax entry then it post successfully.

Thanks in advance.

Kind Regards,

Dineo

0 Kudos

Hi ,

I have pretty much same scenario, issue is my documents is getting post/parked but the Debit/Credit entries are not zero. Can you identify what I am missing below is link to my thread .

Hi Experts,

I am trying to write a mass upload program to park documents using BAPI_ACC_DOCUMENT_POST.

31     960000000(vendor)              1540.00-(ve)

40     406050(G/L)               P1     1400.00+(ve)

40     29500(tax acc)           P1      140 +(Ve)

From the above posting key 31 , end user will supply gross amount(1540) & tax amount(140)

                        posting key 40 (as per screen shot item 2 & 3 ) end user will supply net amount(1400) & tax code (p1) as single entry.

My question is when I am trying to post/park document with the below given structure it actually gives the success message but when see the parked document it looks as below screen shot . As in screen Debit- & Credit are not balanced instead I have no idea how it is getting 1680.00 as Debit?

I will be using FM to CALCULATE_TAX_FROM_NET_AMOUNT or CALCULATE_TAX_FROM_GROSS_AMOUNT with taxcode 'P1' as given with posting key 40 abecause for item '003' in screen user is not proving any details it could be worked out with to get GL etc from FM.

I have shared my current logic . Please correct my logic of where I am missing any essential field in BAPI structure.

lw_acc_vr-itemno_acc = '0000000001'.

lw_Acc_vr-vendor_no = '0096004547'.

lw_acc_vr-comp_code = '8720'.


lw_curr_amt-itemno_acc = '0000000001'.

lw_curr_amt-currency = 'AUD'.

lw_curr_amt-currency_iso = 'AUD'.

lw_curr_amt-amt_doccur = '-1540.00'.


****************************************************************

lw_acc_gl-itemno_acc = '0000000002'.

lw_acc_gl-gl_account = '0000406260'.

lw_acc_gl-item_text = 'tst_value_2'.

lw_acc_gl-doc_type = 'KR'.

lw_acc_gl-comp_code = '8720'.

lw_acc_gl-tax_code = 'P1'.

lw_acc_gl-orderid =   '000008267848'.


lw_curr_amt-itemno_acc = '0000000002'.

lw_curr_amt-currency = 'AUD'.

lw_curr_amt-currency_iso = 'AUD'.

lw_curr_amt-amt_doccur = '1400.00'.

*****************************************************************

lw_acc_tax-itemno_acc = '0000000003'.

lw_acc_tax-gl_account = '0000249500'.

lw_acc_tax-tax_code = 'P1'.

lw_acc_tax-tax_rate = '10.000'.


lw_curr_amt-itemno_acc = '0000000003'.

lw_curr_amt-curr_type = '00'.

lw_curr_amt-currency = 'AUD'.

lw_curr_amt-currency_iso = 'AUD'.

lw_curr_amt-amt_doccur = '140.00'.

lw_curr_amt-amt_base = '1400.00'.


*******************************************************************