09-10-2014 6:00 PM
Hi gurus,
I have an issue.
I'm using BAPI_ACC_DOCUMENT_CHECK, to verify a document before posting. The document needs to have the BKPF-XMWST filled with the value "X".
I've created 2 enhancements for both ACC_DOCUMENT and I added the code:
METHOD if_ex_acc_document~change.
LOOP AT c_accit INTO wa_accit WHERE mwskz IS NOT INITIAL.
wa_accit-xmwst = 'X'.
MODIFY c_accit FROM wa_accit INDEX sy-tabix TRANSPORTING xmwst.
ENDLOOP.
ENDMETHOD.
but the resulting document doesn't have the 3rd line (the tax item) and I get no error message (the document is created).
Is there something I'm missing or did I do something wrong?
Thanks,
Marius
09-10-2014 6:45 PM
Hi
The tax items should be transfered to the BAPI manually, so probably that flag doesn't trigger the process to create the item automatically
Max
09-10-2014 6:45 PM
Hi
The tax items should be transfered to the BAPI manually, so probably that flag doesn't trigger the process to create the item automatically
Max
09-11-2014 8:43 AM
Hi Max,
Found the problem.
The above code is still active.
Here is how my FI document should look like.
And the tables are like this:
2 line in GL accounts 37102 and 37803
1 line in Account Tax 442802
3 lines in Currency amount
Here is the code to it:
ls_accountgl-itemno_acc = 1.
ls_accountgl-gl_account = '0037102000'.
ls_accountgl-de_cre_ind = 'S'.
APPEND ls_accountgl TO lt_accountgl.
ls_accountgl-itemno_acc = 2.
ls_accountgl-gl_account = '0037803000'.
ls_accountgl-tax_code = 'BA'.
ls_accountgl-de_cre_ind = 'H'.
APPEND ls_accountgl TO lt_accountgl.
ls_accounttax-itemno_acc = 3.
ls_accounttax-tax_code = 'BA'.
ls_accounttax-gl_account = '0044280200'.
ls_accounttax-acct_key = 'MWS'.
ls_accounttax-cond_key = 'MWAS'.
APPEND ls_accounttax TO lt_accounttax.
ls_currencyamount-itemno_acc = 1.
ls_currencyamount-currency = 'RON'.
ls_currencyamount-amt_doccur = 1.24.
APPEND ls_currencyamount TO lt_currencyamount.
ls_currencyamount-itemno_acc = 2.
ls_currencyamount-currency = 'RON'.
ls_currencyamount-amt_doccur = -1.
APPEND ls_currencyamount TO lt_currencyamount.
ls_currencyamount-itemno_acc = 3.
ls_currencyamount-currency = 'RON'.
ls_currencyamount-amt_doccur = -0.24.
ls_currencyamount-amt_base = -1.
APPEND ls_currencyamount TO lt_currencyamount.
Thanks,
Marius
09-11-2014 9:00 AM
Yes
but it seems you've transfered the tax item manually, so enhancement should be useless
Max
09-11-2014 9:30 AM
Indeed. I couldn't find a solution for it to do the calculus automatically
If you found one you can share it for the "others" .
Thanks Max.
Marius
09-11-2014 9:36 AM
Hello Marius,
The FM CALCULATE_TAX_FROM_GROSSAMOUNT can be used to calcuate tax amounts.
Populate table accounttax using tax calculated from above FM and pass it to BAPI BAPI_ACC_DOCUMENT_CHECK
Thanks
09-11-2014 9:40 AM
No
I'm sorry as I've written in my first answer the tax item has to be calculated manually: this is my experience of course.
But if I'll find out some news I'll share them
Max
09-11-2014 9:40 AM
I was talking about the "BKPF-XMWST" automation.
Indeed I used the functions to calculate the gross, net, tax values and I gave them to he BAPI.
09-11-2014 9:48 AM
Hello Marius,
If your requirement is to update BKPF-XMWST then read return table of bapi and update BKPF table by using bukrs belnr and year.
Since there is no field for XMWST in DOCUMENTHEADER (BAPI).
Thanks
09-11-2014 9:48 AM
Good
Infact the easier way to calculate the tax is to use function modules like CALCULATE_TAX_FROM_NET_AMOUNT or CALCULATE_TAX_FROM_GROSSAMOUNT
I believe there're several posts about that
Max
09-11-2014 10:07 AM
09-11-2014 10:09 AM
In case some wonders, here
ls_currencyamount-itemno_acc = 3.
ls_currencyamount-currency = 'RON'.
ls_currencyamount-amt_doccur = -0.24.
ls_currencyamount-amt_base = -1.
APPEND ls_currencyamount TO lt_currencyamount.
You can change the amt_base from "-1" (minus), to "1". Some FI detalis ... in my case it's what I had to do to make he document 100% FI proof