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