Skip to Content
Author's profile photo Anil Supraj

line-by-line tax issue while invoice posting

Lately I was working on a requirement where in I had to post an invoice from an idoc.

I have used BAPI_ACC_INVOICE_RECEIPT_POST to post the document.

While I used BAPI_ACC_INVOICE_RECEIPT_POST, I was able to post documents with TAX lines for some Jurisdiction Code Structure but for some I couldn’t.

Bapi threw error – “Taxes by item is activated; consequently, transfer by item is mandatory.” (FF-818)

Later I found the reason being due to a configuration in transaction OBCO, where a checkbox for “tax line-by-line” is checked.


This config meant that for each of line item entered in FB60 or BAPI, tax needs to be calculated individually. In other words, each line item in ACCOUNTGL structure for the bapi has to be linked with corresponding line item of ACCOUNTTAX.

Changing the config was out of question. And after a lot of research I came up with below solution:

1. Fill BAPI extension with a random value

      ls_extn-field1 = ‘TAXLI’.

      ls_extn-field2 = ls_accountgl-itemno_acc.

      APPEND ls_extn TO gt_extn1.

      CLEAR: ls_extn.

2. This extension will be passed to user exit ZXACCU15, where we link ACCOUNTGL with  ACCOUNTTAX.

FIELD-SYMBOLS: <fs_accit> TYPE accit.

FIELD-SYMBOLS: <fs_acctx> TYPE accbset.

READ TABLE extension WITH KEY field1 = ‘TAXLI’.

IF sy-subrc EQ 0.  “Fill the tax line item number for DS and BO2 scenarios

  CLEAR lv_taxline.

  LOOP AT t_accit ASSIGNING <fs_accit> WHERE bapi_param = ‘ACCOUNTTAX’.

    lv_taxline = lv_taxline + 1.

    <fs_accit>-taxps = lv_taxline .


    CLEAR lv_taxline.

  LOOP AT t_accit ASSIGNING <fs_accit> WHERE bapi_param = ‘ACCOUNTGL’.

    lv_taxline = lv_taxline + 1.

    <fs_accit>-taxps = lv_taxline .


  CLEAR lv_taxline.

  LOOP AT t_acctx ASSIGNING <fs_acctx>.

    lv_taxline = lv_taxline + 1.

    <fs_acctx>-taxps = lv_taxline.



UNASSIGN: <fs_accit>, <fs_acctx>.

Linking taxps fields of both structures ensures calculating tax for each item separately.

Alternatively if we are using “BAPI_ACC_DOCUMENT_POST”, solution is simpler

***Because of the implementation of the new notes (1886654 and 1982803) by SAP,

***  we need to pass the itemno_tax field in the BAPI. Otherwise, we get a lin-by-line tax issue

***  Hard-coding the value to 000001

      ls_tax_accnt-itemno_tax = 000001 and ls_accntgl-itemno_tax = 000001.

we have this field itemno_tax in both ACCOUNTGL and ACCOUNTTAX structures in common, which will ensure calculation of tax for each line item individually.

Assigned Tags

      You must be Logged on to comment or reply to a post.
      Author's profile photo Esteban Esteban
      Esteban Esteban

      Ty!! it helps a lot !!

      Author's profile photo Che Eky
      Che Eky

      Thanks this helped when trying to decode the error from IDOC message type FIDCC1.

      Author's profile photo Vikas Desai
      Vikas Desai

      Incase if you are using US country tax code. It uses third party system for tax calculation which is much complex.

      I had same issue while using US tax code, hence I dint not pass Tax Code in the ACCOUNTGL line item and it worked with no error.