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:
|HEADER_TXT||*AP UPLOAD CREDIT|
The ACCOUNTGL contains
|ITEM_TEXT||New fields 4|
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
shown as follows
In ACCOUNTTAX, a record containing the
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