Skip to Content
Author's profile photo Former Member

Calculate tax using SABRIX


  • SAP does not have inbuilt Tax calculation solution, hence external tax bolt on software products are used for tax solution. ‘Sabrix’ is one of the many external tax Software products available as SAP bolt-on. The scope of this document is tax calculation in SAP using SABRIX for North America and Canada regions. As Sabrix is a SAP bolt-on, required information needs to be passed from SAP to Sabrix to calculate tax and receive the results from Sabrix back in SAP.
  • There is a standard interface for passing predetermined fields between SAP and SABRIX. In most cases, the fields available in the standard interface are not enough for effective and efficient tax calculation. Hence some enhancements are required while sending and receiving data between SAP and SABRIX. When the required fields with required information are sent to SABRIX, it returns the Taxable amount and Tax Code which in turn gets posted in SAP. If this exchange of information happens seamlessly, it results in accurate calculation of Tax (or the taxable amount) which is the ultimate aim of using Tax software.


  • There must be communication established between ECC SAP & SABRIX. Communication between these two is established using SAP RFC (Remote Function Calls).
  • There are two ways of communication between SAP and SABRIX:
    • OUTBOUND – SAP sends required data to SABRIX to calculate Tax using RFC (RFC_CALCULATE_TAXES_DOC).
    • INBOUND –     SABRIX returns Taxable amount and Tax Code to SAP through RFC.



Below are the steps required in the configuration of Sabrix. To get the details of each step, please go through the link given below along with the OSS notes.

Below are the configuration steps which are provided for information only and this document will not cover the config part.

  1. The configuration should be done for the communication purpose.
  2. Retrieve the Tax data from external system and testing same.
  3. The Tax Interface System should be activated.
  4. The External Tax Document should be configured.
  5. Structure which defines the tax jurisdiction.
  6. Customize the Tax Indicators for Master Data (MM)
  7. Master data maintenance (MM)
  8. Tax will be configured based on the tax codes.


  • While creating PO manually or by reference of PR/PO, the Taxable amount should be calculated by SABRIX. The Tax Exemption code should be assigned for each PO line item based on the taxable amount. This Tax Exemption
  • Below are the transactions used for tax calculations:
  • ME21N/ME22N/ME23N – Purchase Order Create/Change/Display
  • MIRO, MR8M – Cancel Invoice
  • MRRL  – ERS
  • MRKO – Consignment Invoice
  • MRIS   – Invoice plan settlement
  • MIRO  – background invoice

  • As per requirement, Sabrix should be called for following scenarios:
  1.       If the Cost Center is changed for the PO.
  2.       If the Order (AUFNR) is changed for the PO.
  3.       If the WBS (PS_PSP_PNR) is changed for the PO.

The above three fields were used as part of our requirement. The requirement could be different for other projects and can use different fields as well.


In order to implement this requirement, there are multiple ABAP objects used which are given below in sequence for each scenario.



  • The User exit EXIT_SAPLFYTX_USER_001 (mentioned below in document) is used to pass required data to Sabrix for Tax calculation. The standard fields present in the user exit are not enough to calculate the correct Tax amount for PO. In order to calculate the correct Tax amount, additional fields needs to be passed to the above user exit which is explained in the document below.
  • To send additional fields to the SABRIX, one has to implement Enhancements, BADI’s and Classes. The details and sequence of each are mentioned below.
  • The User Exit can be searched during PO creation/change by using break points on ‘call customer-function’ and it will take you to the User Exit shown below.

A. Enhancement ACCOBL01 (Tax interface)

  • The User Exit can be searched during PO creation/change by using break points on ‘call customer-function’ and it will take you to the User Exit shown below.

          Enhancement ACCOBL01.png

  • It holds the coding block data of PO and can be used to get the current values of PO fields like Cost Center, WBS and Order Number.        

         Enhancement ACCOBL01 -2.png

  • This Enhancement has the component EXIT_SAPLKACB_002 and Include ZXKNTU02.
  • As per requirement, we need to use the existing account assignment field values and validate if they were changed or not during creation/change of PO.
  • This user exit will be helpful in this case because when PO is created OR changed, it will always trigger. It holds the current values (coding block values) of the existing PO created/changed in the COBL structure.
  • We will export cost center, WBS element and order fields from COBL structure. SABRIX will be triggered on change of any of the above fields in order to calculate tax.

          Enhancement ACCOBL01 -3.png

  • We can use the COBL structure to get the current values of Cost Center (KOSTL), Order (AUFNR) and WBS (PS_PSP_PNR) and export the values.


  • This BADI has a method DEFINE_CALCTYPE which is used to set the Pricing Type field value in case of Purchase Order Change/Create and assigns it to the parameter CH_X_LF_CALCTYPE. This indicator is used to call Sabrix.


  • As per requirement, the Sabrix should be called if the Cost Center/Order/WBS is changed for the existing PO.
  • For above scenario of changing the existing Purchase Order, we will check whether the cost Center, Order and WBS was changed or not.
  • The User Exit ACCOBL01 (mentioned above) is used to get the current values of the PO.
  • We will import cost Center, Order and WBS and use it in BADI implementation ME_DEFINE_CALCTYPE. This Badi compares the current values of cost center, Order, WBS with the existing PO values.


In case they are not same then Sabrix should be called and changing parameter CH_X_LF_CALCTYPE will be set which calls Sabrix. Details are mentioned below.


  • Import parameters related to the PO header/Item data:


  • Changing parameter:

CH_X_LF_CALCTYPE (TYPE KOMV-KSTEU) this parameter is pricing type and the below values can be assigned to it. For e.g.: We can use option ‘C’ in case of PO change or Create.

For the new PO’s created, the parameter CH_X_LF_CALCTYPE already has the value as ‘C’ and Sabrix is called.


(Additional data for Tax calculate to SABRIX)

This BADI helps to get the values of Cost Center, Order and WBS element and pass to SABRIX for TAX Calculation.

Below are the methods used in this BADI:


  • Method 1->ME_TAXCOM_MEPO

This method is used to get PO header, item and account assignment data. There are following importing parameters IM_OEKKO, IM_EKKO, IM_OFEKPO, IM_EKPO and IM_ACCOUNTING

Method 1-ME_TAXCOM_MEPO.png

  Method 1-ME_TAXCOM_MEPO-1.png

Parameter IM_ACCOUNTING is the Account Assignment Data for Item. It is a table which contains multiple records.  Following values can available in this table:

Cost center, order number, WBS, G/L Account Number and Project Number. These values can be exported and used further in order to pass to SABRIX.

          E.g. We can check the Account Assignment Category (IM_EKPO-KNTTP) with 3 cases:

    1. Account Assignment = ‘K’ – This is related to the Cost Center. We can use the Cost Center in the IM_ACCOUNTING (KOSTL).
    2. Account Assignment = ‘P’ – This is related to WBS Element. We can use WBS element (PS_PSP_PNR) from IM_ACCOUNTING. Based on this value, actual WBS can be fetched from PRPS table.
    3. Account Assignment = ‘F’ – This is related to the Order number. We can use order (AUFNR) from IM_ACCOUNTING. Based on this value, we can select Order master data from table COAS table.

As per our scenario, we collected the Cost Center, Order and WBS data in the internal table and exported it along with PO item details. We will need these values further in our logic.


(Preparation and Sending of Additional Data for Tax): 

    • The existing standard data passed to Sabrix does not calculate the Tax amount correctly. So, in order to do the correct Tax calculation, additional fields are needed by Sabrix. The details of the additional fields passed are mentioned below in this document.
    • This method has the three importing parameters TI_BSEG, TI_DRSEG and TI_BSEG_MAT.


    • The importing parameter will be used to get the additional data to be passed to the Sabrix.
    • The PO line item data is present in the table TI_BSEG_MAT. We are using below fields as additional data to be send to Sabrix.
    • Material Group, G/L Account Number, Purchasing Document Number, Item Number of Purchasing Document, Reference Document Number, Material Document, Item for the Material Document.

D. Enhancement FYTX0002 (EXIT_SAPLFYTX_USER_001)

    • This User Exit is used for passing the additional data to Sabrix required for Tax Calculation. Details are mentioned below.
    • This Enhancement has the component EXIT_SAPLFYTX_USER_001 and Include ZXFYTU03.
    • This Enhancement is used for Sales and Purchase Order transactions to pass the Field values to the Sabrix for Tax Calculation.
      • Import Parameters are given in below snapshot.

Enhancement FYTX0002.png

      • I_T007A
      • I_TTXD
      • I_TAX_HEADER_INPUT – Not Used in our scenario.
      • I_TAX_ITEM_INPUT – Not Used in our scenario.
      • I_INPUT_USER – This parameter has the standard fields avaiable but does not contaitn the additional fields to pass to Sabrix. In order to calculate the Tax properly, we will append this structure with those additional fields, needed by Sabrix. For      eg. MATKL, KUNNR, AUART, WERKS etc.

     Enhancement FYTX0002-1.png

      • Using this Enhancement, the additional fields given below can be passed to the Sabrix for Tax calculation:

Material Group, Plant Number, Cost Center, G/L Account Number, Internal Order, PO Line Type, (item category), PO Account Assignment Indicator, Material Type, Cost Center Category, Invoice Header Reference, Profit Center, Project No.

      • In order to pass the additional fields we need to enhance the structure TAX_ALLOWED_FIELDS of the CHANGING Parameter CH_USER_CHANGED_FIELDS.

                         Enhancement FYTX0002-2.png

                         Below Struture is appended with the Attribute fields which will hold additional fields.

                         Enhancement FYTX0002-3.png

                         Enhancement FYTX0002-4.png

      • The additional fields like zzattribute16 (Cost Center), zzattribute18 (ORDER) and zzattribute21 (WBS) etc. were passed to Sabrix in our scenario.  Similarly, all the fields described in the structure above were passed to Sabrix.
      • This User Exit will run for multiple transactions such as ME21, ME21N, ME22, ME22N, ME23, ME23N, MIRO, MRRL, MRIS, MRKO, FB60, FB65, and ML81N. Based on the requirement, one can add the logic respectively to pass the fields to Changing structure.

                         Enhancement FYTX0002-5.png

      • In the above screenshot, we are passing Cost Center (KOSTL), Cost element (SAKTO), Order Number (AUFNR), Item Category (PSTYP), Account Assignment Category (KNTTP), Material Type (MTART) and Profit Center (PRCTR) in the ZZATTRIBUTE fields.



  • Once the changing structure CH_USER_CHANGED_FIELDS shown above is populated with all the required ZZATTRIBUTE fields, the same structure is already appended with the Input table TAX_CAL_ITEM_INXX of the Sabrix RFC. Scroll down for details.
  • Please see the below snapshots.

          Structure of CH_USER_CHANGED_FIELDS

          SABRIX CALL.png

          Structure of Sabrix RFC Input table

          SABRIX CALL-1.png

  • Once the structure is populated, the RFC will have the updated values in the input table TAX_CAL_ITEM_INXX to send to Sabrix. The SABRIX is called through the RFC RFC_CALCULATE_TAXES_DOC and returns the taxable amount. The input field values are provided by table TAX_CAL_ITEM_INXX and the Taxable amount is returned in the table TAX_CAL_ITEM_OUTXX.

          SABRIX CALL-2.png

  • We can read the RFC table TAX_CAL_ITEM_OUTXX and get the taxable amount in the field TAXAMOV.


A. Transactions Used For Purchase Order

  • Generate the Purchase Order: ME21N and ME21.
  • Change Existing Purchase Order : ME22N and ME22
  • Display the Purchase Order: ME23N and ME23.

B. Custom Table Creation

  • A custom Maintainable Control table was created to hold the Tax Exemption
  • This table will be maintained by user with the below given fields.

     Custom Table.png

  • There are 5 tax Exemption codes associated with each PO line item. i.e. A1, A2, A3, A4, A5.
  • Each Tax Exemption Code has a description given in the table below and is used in Purchase Order form output as per the tax Exemption code assigned to each line item of PO.
  • Tax Exemption codesRFC_CALCULATE_TAXES_DOC) and will be assigned to the PO line item and displayed on the screen(Logic for tax Exemption code will be covered in enhancement below).
  • Tax Exemption Codes A4 and A5 will be added with custom logic as per or scenario

     Custom Table-1.png

C. Enhancement Implementation

  • The Sabrix is called for each line item to calculate tax. In order to get the line item number, an Implicit Enhancement ZMM_LINEITEM_GET was created in the inlcude LFYTX_TAXMF12. The line item determined this way will help in placing the correct Tax Exemption Code on the PO screen.

        Enhancement Implementation zmm_lineitem_get.png

  • This enhancement is called after SABRIX returns tax information so that the correct line item number can be used to populate Tax Exemption Code.
  • The line item number is exported to the memory ID to use it further.

     Enhancement Implementation zmm_lineitem_get -1.png

D. Enhancement Implementation (ZMM_TAXCODE_GET)

  • This enhancement implementation was created once the SABRIX RFC returns the data. Also this Enhancement was created just after the RFC_CALCULATE_TAXES_DOC in the code in order  to utilize the data returned by SABRIX.

     Enhancement Implementation zmm_taxcode_get.png

     Enhancement Implementation zmm_taxcode_get-1.png

  • The line number exported above can be imported here so that the Tax Exemption Code can be assigned for respective line item.
  • To get the tax Exemption code and taxable amount returned by SABRIX, Read the table TAX_CAL_ITEM_OUTXX which is output of SABRIX RFC.
  • The tax amount will be in the field TAXAMOV of the table TAX_CAL_ITEM_OUTXX
  • The tax Exemption code Returned from SABRIX will be in the field EXT_EXREASON of the same table.

     Enhancement Implementation zmm_taxcode_get-2.png

  • The tax Exemption code A1, A2 and A3 will be returned from the SABRIX in the field EXT_EXREASON and A4/A5 will be assigned by the logic in code depending on the taxable amount.

        Logic To Calculate Tax Exemption Code A4 and A5

  • Tax Exemption code A1, A2 and A3 are standard and will be returned by Sabrix RFC. But as per our requirement, we need A4 and A5 which explained below how to determine these Tax Exemption codes.
  • Check the taxable amount (TAX_CAL_ITEM_OUTXX – TAXAMOV) returned by the SABRIX.
  • When taxable amount = 0, for a particular line item and the tax ExemptionExemption code to populate the PO Customer data Screen field(Sabrix tax Exemption code). In case the SABRIX do not return the tax ExemptionExemption code, Then use tax Exemption code as ‘A4’. This mean TAX EXEMPT.
  • If the taxable amount is NOT 0, for a particular line item and the Tax ExemptionExemption codeExemption Code). In case the SABRIX doesn’t return the tax Exemptiontax Exemption, Then use tax Exemption code as ‘A5’. This mean TAXABLE amount.

       (See the Code Snippet 1 as an attachment)

  • Collect the tax Exemption code for each item in the internal table and export the internal table.

     Enhancement Implementation zmm_taxcode_get-3.png

          This table will be used further in the inlcude ZXM06O03(Detail given below) to assign the Tax Exemption Code to the PO Customer Data           Screen.

E. EXIT_SAPMM06E_018 (Include ZXM06U40)

This user exit will populate the Tax Exemption Code for each line item to the structure E_CI_EKPO. This structure hold the tax Exemption code and will be populated on the PO customer Tab screen while displaying the Purchase order.

EXIT_SAPMM06E_018 (Include ZXM06U40).png

EXIT_SAPMM06E_018 (Include ZXM06U40) -1.png

EXIT_SAPMM06E_018 (Include ZXM06U40) -2.png

F.   Assign Tax Exemption Code to Customer Tab of PO

The Screen to add the Sabrix Tax Exemption Code field is SAPLXM06 (011) .

Assign Tax Code to Customer Tab of PO.png

A custom include ZXM06ZZZ was created for all the subprograms and modules.

Inside this include, another custom include ZXM06O03 contains the code to get the Tax  Exemption Code from Sabrix and assign to the Screen Field Tax Exemption Code.

Code Snippet2:

  • The PO below has been assigned TaxCode  as ‘A1’ for Line item 10. Simillarly, Line item 20 and  30 has been assigned TAXCODE as A5 because the Tax is calculated for each line item. Please go through below screen shots.

     Assign Tax Code to Customer Tab of PO -1.png

     Assign Tax Code to Customer Tab of PO -2.png

     Assign Tax Code to Customer Tab of PO -3.png

  • Sabrix EX Code is the custom functionality added per requirement.
  • This field is added in ‘Customer data’ tab of ME21N/ME22N/ME23N transaction, this field will be filled in EXIT_SAPMM06E_018 from sabrix data by enhancing the structure CI_EKPODB for EKPO table.

     Assign Tax Code to Customer Tab of PO -4.png

Assigned Tags

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

      Great Job Mandeep....

      Author's profile photo David Sosa
      David Sosa

      Not Supported out of US. Big problem for global templates