Download as pdf or txt
Download as pdf or txt
You are on page 1of 22

10/3/2019 Calculate tax using SABRIX | SAP Blogs

Community

Ask a Question Write a Blog Post Login

Former Member
September 28, 2014 15 minute read

Calculate tax using SABRIX


Follow RSS feed Like

6 Likes 14,619 Views 2 Comments

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.

1. The configura on should be done for the communica on purpose.


2. Retrieve the Tax data from external system and tes ng same.
3. The Tax Interface System should be ac vated.
https://blogs.sap.com/2014/09/28/calculate-tax-using-sabrix/ 2/22
10/3/2019 Calculate tax using SABRIX | SAP Blogs

4. The External Tax Document should be configured.


5. Structure which defines the tax jurisdic on.
6. Customize the Tax Indicators for Master Data (MM)

7. Master data maintenance (MM)


8. Tax will be configured based on the tax codes.

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

As per requirement, Sabrix should be called for following scenarios:

a. If the Cost Center is changed for the PO.


b. If the Order (AUFNR) is changed for the PO.
c. 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.

STEPS FOR SOLUTION


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

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.

A. Enhancement ACCOBL01 (Tax interface)


https://blogs.sap.com/2014/09/28/calculate-tax-using-sabrix/ 4/22
10/3/2019 Calculate tax using SABRIX | SAP Blogs

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.

This Enhancement has the component EXIT_SAPLKACB_002 and Include ZXKNTU02.


As per requirement, we need to use the exis ng account assignment field values and validate if they were
changed or not during crea on/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 exis ng 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.

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.

B. Implement BADI ME_DEFINE_CALCTYPE.


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 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

Import parameters related to the PO header/Item data:

IM_X_OEKKO, IM_X_NEKKO, IM_X_OEKPO, IM_X_NEKPO, IM_X_OBEKPO, IM_X_NBEKPO,


IM_X_ACC_CH.

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.

C. Implement BADI-> EXTENSION_US_TAXES


(Addi onal 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
Calcula on.
Below are the methods used in this BADI:

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

(Prepara on and Sending of Addi onal Data for Tax):

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.

D. Enhancement FYTX0002 (EXIT_SAPLFYTX_USER_001)


This User Exit is used for passing the addi onal data to Sabrix required for Tax Calcula on. Details are
men oned below.
This Enhancement has the component EXIT_SAPLFYTX_USER_001 and Include ZXFYTU03.
This Enhancement is used for Sales and Purchase Order transac ons to pass the Field values to the
Sabrix for Tax Calcula on.
Import Parameters are given in below snapshot.

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

I_TAX_ITEM_INPUT – Not Used in our scenario.


I_INPUT_USER – This parameter has the standard fields avaiable but does not contaitn the
addi onal fields to pass to Sabrix. In order to calculate the Tax properly, we will append this
structure with those addi onal fields, needed by Sabrix. For eg. MATKL, KUNNR, AUART, WERKS
etc.

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

(MTART) and Profit Center (PRCTR) in the ZZATTRIBUTE fields.

E. SABRIX CALL (RFC_CALCULATE_TAXES_DOC)


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

Structure of Sabrix RFC Input table

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.

B. Custom Table Crea on


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

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.

D. Enhancement Implementation (ZMM_TAXCODE_GET)


This enhancement implementa on was created once the SABRIX RFC returns the data. Also this
Enhancement was created just a er the RFC_CALCULATE_TAXES_DOC in the code in order to u lize the
data returned by SABRIX.

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.

Logic To Calculate Tax Exemp on Code A4 and A5

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

‘A5’. This mean TAXABLE amount.

(See the Code Snippet 1 as an a achment)

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.

E. EXIT_SAPMM06E_018 (Include ZXM06U40)


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

https://blogs.sap.com/2014/09/28/calculate-tax-using-sabrix/ 17/22
10/3/2019 Calculate tax using SABRIX | SAP Blogs

F. Assign Tax Exemp on Code to Customer Tab of PO


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

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

Sabrix EX Code is the custom func onality added per requirement.


This field is added in ‘Customer data’ tab of ME21N/ME22N/ME23N transac on, this field will be filled in
EXIT_SAPMM06E_018 from sabrix data by enhancing the structure CI_EKPODB for EKPO table.

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 Blog Posts

Working with SABRIX when Japanese Entity is Involved


By Former Member , Apr 11, 2016
ACCOUNTTAX in BAPI_ACC_DOCUMENT_POST
By Former Member , Jul 23, 2013
Calculate Mandelbrot set in ABAP
By Former Member , Oct 15, 2014

Related Questions

How to mark calculate tax using BAPI_INCOMINGINVOICE_PARK?


By Christian Leyva , Feb 20, 2017

Calculate tax exemption amount in BAPI_ACC_DOCUMENT_POST


By Manish Malakar , Jan 28, 2019
POSTING_INTERFACE_DOCUMENT FB01 Tax Issue Even after giving tax code
By Sandeep Kumar Manne , Aug 02, 2017

2 Comments
https://blogs.sap.com/2014/09/28/calculate-tax-using-sabrix/ 21/22
10/3/2019 Calculate tax using SABRIX | SAP Blogs

You must be Logged on to comment or reply to a post.

Former Member

March 31, 2015 at 2:38 pm

Great Job Mandeep….

Like (0)

David Sosa

December 12, 2018 at 7:51 pm

Not Supported out of US. Big problem for global templates

Like (0)

Share & Follow

Privacy Terms of Use

Legal Disclosure Copyright

Trademark Cookie Preferences

Sitemap

Newsletter

https://blogs.sap.com/2014/09/28/calculate-tax-using-sabrix/ 22/22

You might also like