Application Development Blog Posts
Learn and share on deeper, cross technology development topics such as integration and connectivity, automation, cloud extensibility, developing at scale, and security.
cancel
Showing results for 
Search instead for 
Did you mean: 
former_member202771
Contributor
34,149

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 .

  ENDLOOP.

    CLEAR lv_taxline.

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

    lv_taxline = lv_taxline + 1.

    <fs_accit>-taxps = lv_taxline .

  ENDLOOP.

  CLEAR lv_taxline.

  LOOP AT t_acctx ASSIGNING <fs_acctx>.

    lv_taxline = lv_taxline + 1.

    <fs_acctx>-taxps = lv_taxline.

  ENDLOOP.

ENDIF.

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.

4 Comments
Labels in this area