ACCOUNTTAX in BAPI_ACC_DOCUMENT_POST
After poring over SDN for hours together, I discovered that there was no one document which detailed the posting of FI Documents with Tax lines. This post is an endeavour to make it easier for other looking for the similar content.
While posting FI documents, for example vendor invoices in FB60. We have an option of posting tax amount and doing this via ABAP via the BAPI_ACC_DOCUMENT_POST/BAPI_ACC_DOCUMENT_CHECK has proven to be tricky in my experience.
This post will primarily deal with vendor invoices and will be used to detail the posting of tax data via BAPI_ACC_DOCUMENT_POST/BAPI_ACC_DOCUMENT_CHECK
The Tax Data can be seen for the relevant documents via the transaction FB03
The post will detail the posting of tax data with the Tax Code T1 and Tax Jurisdiction TJ000000 as shown above
The DOCUMENTHEADER, ACCOUNTGL, ACCOUNTPAYABLE and CURRENCY AMOUNT will be populated as per the normal processing of the BAPI_ACC_DOCUMENT_CHECK/POST
The file that has been attached has been used as an example to detail the scenario.
The DOCUMENTHEADER will contain the following details:
Field | Value |
USERNAME | SY-UNAME |
HEADER_TXT | *AP UPLOAD CREDIT |
COMP_CODE | 1001 |
DOC_DATE | 20130102 |
PSTNG_DATE | 20130708 |
TRANS_DATE | 00000000 |
FISC_YEAR | 2013 |
FIS_PERIOD | 00 |
DOC_TYPE | KR |
REF_DOC_NO | CREDIT-8 |
The ACCOUNTGL contains
Field | Value |
---|---|
ITEMNO_ACC |
0000000002 |
GL_ACCOUNT |
0000677000 |
ITEM_TEXT | New fields 4 |
COMP_CODE | 1008 |
TAX_CODE | I1 |
TAXJURCODE | TJ000000 |
COSTCENTER | 10013 |
The ACCOUNTPAYABLE contains
The CURRENCYAMOUNT would, in the normal scenario, have only 2 items containing the vendor and account payable amount information. As you might already know, this table contains all the currency amounts relating to the document. In a normal financial document without any tax data, the table GT_CURRENCYAMOUNT would contain the following
Since our document contains tax data, we need to populate the ACCOUNTTAX table which is used exclusively to populate the tax data and we also need to populate a dummy line item in the CURRENCYAMOUNT internal table with both the ITEMNO_ACC being the same. In this case, the ITEMNO_ACC would be ‘0000000003’ and the CURRENCYAMOUNT table would be updated with the third line item containing the
- ITEMNO_ACC
- CURRENCY
- AMT_DOCCUR
- TAX_AMT
- AMT_BASE
shown as follows
In ACCOUNTTAX, a record containing the
- ITEMNO_ACC
- GL_ACCOUNT
- COND_KEY
- ACCT_KEY
- TAX_CODE
- TAXJURCODE
are populated. As shown below:
In the current scenario, the tax code and tax jurisdiction is provided by the user. Based on which the COND_KEY and ACCT_KEY are decided using the function module ‘CALCULATE_TAX_FROM_NET_AMOUNT’ In this case, user had provided us with the tax amount and the base amount, but if the tax amount is not provided, various function modules can be used to calculate the tax based on the base amount.
The common error that is encountered while posting tax data is ‘FI/CO interface: Balance in transaction currency’ This comes up if the amounts in the table CURRENCYAMOUNT-AMT_DOCCUR do not balance. ABAPers need to make sure that the amounts balance exactly as shown below
Hello Sarala,
Well appreciated to share your knowledge through blog post,good explanation.
Regard's,
Shashi Kanth.
May be because SAP has provided a demo program on how to use the a/c'ing BAPIs - BAPI_ACC_DOCUMENT_CHECK & BAPI_ACC_DOCUMENT_POST.
BR,
Suhas
Hey Suhas,
Could you please share the name of the demo program. It would be a great help! I had searched for a demo program which gave an example of posting tax line items. But couldn't find it, hence the post.
Thanks in advance!
Hi Sarala,
Thanks for sharing....
Regards,
Ramesh.T
Good one Sarala...
Keep sharing the knowledge .. 🙂
Regards
Kiran N
Olá Sarala, sou novo em programação ABAP,
gostaria de agradecer pelo post, me ajudou a entender.
Abraços.
Wanderson Sampaio
Hi Sarala,
could you please explain me how the values are being calculated for item no 3 in currency structure.
also which gl account need to be used in accountax structure.
thanks in advance.
regards,
priyaranjan
Hello,
I have done everything like you've described in below blog but I get an error F5704 -> Inconsistent amounts. I've been searching OSS but I haven't find anything. Could you help me with this issue?
I will be gratefull.
Best Regards,
Miko
Hello,
I agree with Mikolaj ..This solution doesn't work.
I have found useful .thanks