Skip to Content
Author's profile photo Former Member

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

FB03.jpg

FB03-1.jpg

FB03 - 2.jpg

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

DOCUMENTHEADER.jpg

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

ACCOUNTGL.jpg

The ACCOUNTPAYABLE contains

ACCOUNTPAYABLE.jpg

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

CURRENCYAMOUNT_No Tax.jpg

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

CURRENCYAMOUNT_Tax.jpg

In ACCOUNTTAX, a record containing the

  • ITEMNO_ACC
  • GL_ACCOUNT
  • COND_KEY
  • ACCT_KEY
  • TAX_CODE
  • TAXJURCODE

are populated. As shown below:

ACCOUNTTAX.jpg

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

CURRENCYAMOUNT_Balance.jpg

Assigned Tags

      10 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Shashi Kanth
      Shashi Kanth

      Hello Sarala,

      Well appreciated to share your knowledge through blog post,good explanation.

      Regard's,

      Shashi Kanth.

      Author's profile photo Former Member
      Former Member

      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.

      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

      Author's profile photo Former Member
      Former Member
      Blog Post Author

      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!

      Author's profile photo Ramesh T
      Ramesh T

      Hi Sarala,

      Thanks for sharing....

      Regards,

      Ramesh.T

      Author's profile photo Former Member
      Former Member

      Good one Sarala...

      Keep sharing the knowledge .. 🙂

      Regards

      Kiran N

      Author's profile photo Former Member
      Former Member

      Olá Sarala, sou novo em programação ABAP,

      gostaria de agradecer pelo post, me ajudou a entender.

      Abraços.

      Wanderson Sampaio

      Author's profile photo Priyaranjan Gupta
      Priyaranjan Gupta

      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

      Author's profile photo Former Member
      Former Member

      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

      Author's profile photo Drashti Amrutia
      Drashti Amrutia

      Hello,

      I agree with Mikolaj ..This solution doesn't work.

      Author's profile photo Vishal Nangia
      Vishal Nangia

      I have found useful .thanks