Professional Documents
Culture Documents
Calculate Tax Using SABRIX - SAP Blogs
Calculate Tax Using SABRIX - SAP Blogs
Community
Former Member
September 28, 2014 15 minute read
INTRODUCTION
SAP does not have inbuilt Tax calcula on solu on, hence external tax bolt on so ware products are used for
tax solu on. ‘Sabrix’ is one of the many external tax So ware products available as SAP bolt-on. The scope
of this document is tax calcula on in SAP using SABRIX for North America and Canada regions. As Sabrix is a
SAP bolt-on, required informa on 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 effec ve and efficient tax calcula on. Hence
some enhancements are required while sending and receiving data between SAP and SABRIX. When the
required fields with required informa on are sent to SABRIX, it returns the Taxable amount and Tax Code
which in turn gets posted in SAP. If this exchange of informa on happens seamlessly, it results in accurate
calcula on of Tax (or the taxable amount) which is the ul mate aim of using Tax so ware.
ARCHITECTURE
https://blogs.sap.com/2014/09/28/calculate-tax-using-sabrix/ 1/22
10/3/2019 Calculate tax using SABRIX | SAP Blogs
There must be communica on established between ECC SAP & SABRIX. Communica on between these two
is established using SAP RFC (Remote Func on Calls).
There are two ways of communica on 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.
CONFIGURATION
Below are the steps required in the configura on of Sabrix. To get the details of each step, please go through the link given
below along with the OSS notes.
h p://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/047ab790-0201-0010-a9b1-e612f8b71dcd?
overridelayout=true
Below are the configura on steps which are provided for informa on only and this document will not cover the config part.
REQUIREMENT
While crea ng PO manually or by reference of PR/PO, the Taxable amount should be calculated by SABRIX.
The Tax Exemp on code should be assigned for each PO line item based on the taxable amount. This Tax
Exemp on
Below are the transac ons used for tax calcula ons:
ME21N/ME22N/ME23N – Purchase Order Create/Change/Display
MIRO, MR8M – Cancel Invoice
MRRL – ERS
MRKO – Consignment Invoice
MRIS – Invoice plan se lement
MIRO – background invoice
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.
https://blogs.sap.com/2014/09/28/calculate-tax-using-sabrix/ 3/22
10/3/2019 Calculate tax using SABRIX | SAP Blogs
OUTBOUND
The User exit EXIT_SAPLFYTX_USER_001 (men oned below in document) is used to pass required data to
Sabrix for Tax calcula on. 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, addi onal fields needs to be passed to the
above user exit which is explained in the document below.
To send addi onal fields to the SABRIX, one has to implement Enhancements, BADI’s and Classes. The
details and sequence of each are men oned below.
The User Exit can be searched during PO crea on/change by using break points on ‘call customer-func on’
and it will take you to the User Exit shown below.
The User Exit can be searched during PO crea on/change by using break points on ‘call customer-func on’
and it will take you to the User Exit shown below.
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.
https://blogs.sap.com/2014/09/28/calculate-tax-using-sabrix/ 5/22
10/3/2019 Calculate tax using SABRIX | SAP Blogs
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.
As per requirement, the Sabrix should be called if the Cost Center/Order/WBS is changed for the exis ng
PO.
For above scenario of changing the exis ng Purchase Order, we will check whether the cost Center, Order
and WBS was changed or not.
The User Exit ACCOBL01 (men oned above) is used to get the current values of the PO.
We will import cost Center, Order and WBS and use it in BADI implementa on ME_DEFINE_CALCTYPE. This
Badi compares the current values of cost center, Order, WBS with the exis ng 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 men oned below.
https://blogs.sap.com/2014/09/28/calculate-tax-using-sabrix/ 6/22
10/3/2019 Calculate tax using SABRIX | SAP Blogs
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 op on ‘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.
Method 1->ME_TAXCOM_MEPO
https://blogs.sap.com/2014/09/28/calculate-tax-using-sabrix/ 7/22
10/3/2019 Calculate tax using SABRIX | SAP Blogs
This method is used to get PO header, item and account assignment data. There are following
impor ng parameters IM_OEKKO, IM_EKKO, IM_OFEKPO, IM_EKPO and IM_ACCOUNTING
Parameter IM_ACCOUNTING is the Account Assignment Data for Item. It is a table which contains
mul ple 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.
Method 2->MM_DATA_FOR_TAX_SYSTEM
The exis ng standard data passed to Sabrix does not calculate the Tax amount correctly. So, in order to
do the correct Tax calcula on, addi onal fields are needed by Sabrix. The details of the addi onal fields
passed are men oned below in this document.
https://blogs.sap.com/2014/09/28/calculate-tax-using-sabrix/ 8/22
10/3/2019 Calculate tax using SABRIX | SAP Blogs
This method has the three impor ng parameters TI_BSEG, TI_DRSEG and TI_BSEG_MAT.
The impor ng parameter will be used to get the addi onal 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 addi onal 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.
I_T007A
I_TTXD
I_TAX_HEADER_INPUT – Not Used in our scenario.
https://blogs.sap.com/2014/09/28/calculate-tax-using-sabrix/ 9/22
10/3/2019 Calculate tax using SABRIX | SAP Blogs
Using this Enhancement, the addi onal fields given below can be passed to the Sabrix for Tax
calcula on:
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 addi onal fields we need to enhance the structure TAX_ALLOWED_FIELDS of
the CHANGING Parameter CH_USER_CHANGED_FIELDS.
Below Struture is appended with the A ribute fields which will hold addi onal fields.
https://blogs.sap.com/2014/09/28/calculate-tax-using-sabrix/ 10/22
10/3/2019 Calculate tax using SABRIX | SAP Blogs
The addi onal fields like zza ribute16 (Cost Center), zza ribute18 (ORDER) and zza ribute21
(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 mul ple transac ons 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 respec vely to pass the fields to Changing structure.
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
https://blogs.sap.com/2014/09/28/calculate-tax-using-sabrix/ 11/22
10/3/2019 Calculate tax using SABRIX | SAP Blogs
Structure of CH_USER_CHANGED_FIELDS
https://blogs.sap.com/2014/09/28/calculate-tax-using-sabrix/ 12/22
10/3/2019 Calculate tax using SABRIX | SAP Blogs
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.
We can read the RFC table TAX_CAL_ITEM_OUTXX and get the taxable amount in the field TAXAMOV.
INBOUND
A. Transac ons Used For Purchase Order
Generate the Purchase Order: ME21N and ME21.
Change Exis ng Purchase Order : ME22N and ME22
Display the Purchase Order: ME23N and ME23.
https://blogs.sap.com/2014/09/28/calculate-tax-using-sabrix/ 13/22
10/3/2019 Calculate tax using SABRIX | SAP Blogs
There are 5 tax Exemp on codes associated with each PO line item. i.e. A1, A2, A3, A4, A5.
Each Tax Exemp on Code has a descrip on given in the table below and is used in Purchase Order form
output as per the tax Exemp on code assigned to each line item of PO.
Tax Exemp on codesRFC_CALCULATE_TAXES_DOC) and will be assigned to the PO line item and displayed
on the screen(Logic for tax Exemp on code will be covered in enhancement below).
Tax Exemp on Codes A4 and A5 will be added with custom logic as per or scenario
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 Exemp on Code on the PO screen.
https://blogs.sap.com/2014/09/28/calculate-tax-using-sabrix/ 14/22
10/3/2019 Calculate tax using SABRIX | SAP Blogs
This enhancement is called a er SABRIX returns tax informa on so that the correct line item number can be
used to populate Tax Exemp on Code.
The line item number is exported to the memory ID to use it further.
https://blogs.sap.com/2014/09/28/calculate-tax-using-sabrix/ 15/22
10/3/2019 Calculate tax using SABRIX | SAP Blogs
The line number exported above can be imported here so that the Tax Exemp on Code can be assigned for
respec ve line item.
To get the tax Exemp on 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 Exemp on code Returned from SABRIX will be in the field EXT_EXREASON of the same table.
The tax Exemp on 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.
Tax Exemp on 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 Exemp on codes.
Check the taxable amount (TAX_CAL_ITEM_OUTXX – TAXAMOV) returned by the SABRIX.
When taxable amount = 0, for a par cular line item and the tax Exemp onExemp on code to populate the
PO Customer data Screen field(Sabrix tax Exemp on code). In case the SABRIX do not return the tax
Exemp onExemp on code, Then use tax Exemp on code as ‘A4’. This mean TAX EXEMPT.
If the taxable amount is NOT 0, for a par cular line item and the Tax Exemp onExemp on codeExemp on
Code). In case the SABRIX doesn’t return the tax Exemp ontax Exemp on, Then use tax Exemp on code as
https://blogs.sap.com/2014/09/28/calculate-tax-using-sabrix/ 16/22
10/3/2019 Calculate tax using SABRIX | SAP Blogs
Collect the tax Exemp on code for each item in the internal table and export the internal table.
This table will be used further in the inlcude ZXM06O03(Detail given below) to assign the Tax Exemp on
Code to the PO Customer Data Screen.
https://blogs.sap.com/2014/09/28/calculate-tax-using-sabrix/ 17/22
10/3/2019 Calculate tax using SABRIX | SAP Blogs
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 Exemp on
Code from Sabrix and assign to the Screen Field Tax Exemp on 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.
https://blogs.sap.com/2014/09/28/calculate-tax-using-sabrix/ 18/22
10/3/2019 Calculate tax using SABRIX | SAP Blogs
https://blogs.sap.com/2014/09/28/calculate-tax-using-sabrix/ 19/22
10/3/2019 Calculate tax using SABRIX | SAP Blogs
https://blogs.sap.com/2014/09/28/calculate-tax-using-sabrix/ 20/22
10/3/2019 Calculate tax using SABRIX | SAP Blogs
Alert Moderator
Assigned tags
ABAP Development |
Related Questions
2 Comments
https://blogs.sap.com/2014/09/28/calculate-tax-using-sabrix/ 21/22
10/3/2019 Calculate tax using SABRIX | SAP Blogs
Former Member
Like (0)
David Sosa
Like (0)
Sitemap
Newsletter
https://blogs.sap.com/2014/09/28/calculate-tax-using-sabrix/ 22/22