Sie sind auf Seite 1von 7

Building a Tax Calculation Application

PDF download from SAP Help Portal:


http://help.sap.com/saphelp_dsm10/helpdata/de/a5/2fc6e13062420a9f975cb21ef5784a/content.htm
Created on June 11, 2014

The documentation may have changed since you downloaded the PDF. You can always find the latest information on SAP Help Portal.

Note
This PDF document contains the selected topic and its subtopics (max. 150) in the selected structure. Subtopics from other structures are not included.

2014 SAP AG or an SAP affiliate company. All rights reserved. No part of this publication may be reproduced or transmitted in any form or for any purpose
without the express permission of SAP AG. The information contained herein may be changed without prior notice. Some software products marketed by SAP AG
and its distributors contain proprietary software components of other software vendors. National product specifications may vary. These materials are provided by
SAP AG and its affiliated companies ("SAP Group") for informational purposes only, without representation or warranty of any kind, and SAP Group shall not be
liable for errors or omissions with respect to the materials. The only warranties for SAP Group products and services are those that are set forth in the express
warranty statements accompanying such products and services, if any. Nothing herein should be construed as constituting an additional warranty. SAP and other
SAP products and services mentioned herein as well as their respective logos are trademarks or registered trademarks of SAP AG in Germany and other
countries. Please see www.sap.com/corporate-en/legal/copyright/index.epx#trademark for additional trademark information and notices.

Table of content

PUBLIC
2014 SAP AG or an SAP affiliate company. All rights reserved.

Page 1 of 7

Table of content
1 Building a Tax Calculation Application
1.1 Creating an Application
1.2 Creating a Function
1.3 Creating Formula Expressions
1.4 Creating Value Range Expressions
1.5 Adding Values to the Decision Tree Expression
1.6 Simulating the Function

PUBLIC
2014 SAP AG or an SAP affiliate company. All rights reserved.

Page 2 of 7

1 Building a Tax Calculation Application


Use
In this tutorial, you learn to model an application for calculating the income tax amount to be deducted from an employee's salary. The application processes the
user input and calculates the tax amount to be paid.

Prerequisites
You have a basic knowledge of BRFplus.

Procedure
The tutorial consists of the following steps:
1.
2.
3.
4.
5.
6.

Creating an Application
Creating a Function
Creating Formula Expressions
Creating Value Range Expressions
Adding Values to a Decision Tree Expression
Simulating the Function

Next Step
Creating an Application

1.1 Creating an Application


Procedure
1. In the menu bar, choose
Workbench
Create Application...
2. In the Object Creation dialog box that appears, enter Z_Tax_Calculations in the Name field. Also, provide a short text and a text. Although both
fields are optional, providing texts is always recommended for easier identification and documentation.
3. Choose System as the storage type and select the Create Local Application check box.
$TMP appears in the Development Package field. This is the package placeholder used for local development objects.
4. Choose Create and navigate to object .
The application opens in the Object Manager panel.
5. Save and activate the application.

Result
Your application is created.
Next Step
Creating a Function

1.2 Creating a Function


Use
With the newly created application in the Object Manager panel still open, we now proceed with adding elements to the application. The first object we need is a
function that serves as an interface between the calling application and the internal business logic modeled with BRFplus.

Procedure
1. Create a Function
1. In the Object Manager panel of the application that you just have created, under the Detail section, choose the Contained Objects tab.
The Contained Objects tab page appears.
2. Choose Function from the Type field and choose Create Object .
3. In the Object Creation dialog box that appears, enter Tax_Calculator in the Name field and choose Create and navigate to object .
The function is created and opens in the Object Manager panel.
2. Assign Top Expression to the Function
1. Under the Detail section on the Properties tab of the new application, select Functional Mode as Mode .
The Top Expression field appears.
2. Choose next to the Top Expression field.
3. In the context menu, choose Create ... .
4. In the Object Creation dialog box that appears, choose Decision Tree in the Type field and enter Tax_Calculation in the Name field.
5. Choose Create .
Top expression Tax_Calculation is now assigned to the Tax_Calculator function.
3. Assign Context Data Object to the Function
1. Under the Detail section, choose the Signature tab.
The Signature tab page opens.

PUBLIC
2014 SAP AG or an SAP affiliate company. All rights reserved.

Page 3 of 7

2. Under Context , choose


Add New Data Object
Add New Data Object .
3. In the Object Creation dialog box that appears, enter Gross_Salary in the Name field.
4. Choose Amount from the Element Type field.
5. Choose Create .
The data object is added as the context.
4. Assign Result Data Object to the Function
1. 1. Under the Detail section, choose the Signature tab.
2. Under Result Data Object , choose next to the Result Data Object field.
3. In the context menu, choose Create... .
4. In the Object Creation dialog box that appears, enter Payable_Tax_Amount in the Name field and Amount to be paid in the Text field.
5. Choose Amount from the Element Type field.
6. Choose Create .
The data object is added as the result data object.
5. Save the function.
Next Step
Creating Formula Expressions

1.3 Creating Formula Expressions


Use
In this step, we will build up a simple taxation model with three different tax calculation formulas for low, mid, and high incomes. The general approach is to divide
an employee's gross salary into three segments and apply an individual tax rate to each of the segments (progressive taxation). The resulting tax amount for each
segment will then be added to the total tax amount to be paid on the gross salary. The formula expressions will later be used in a decision tree.

Procedure
1. To create the formula expression, you have to navigate to the application in the Object Manager panel. To do so, choose the Back button. (You could as
well choose the application from the Recently Used list.)
2. Under the Detail section, choose the Contained Objects tab.
The Contained Objects tab page opens.
3. Choose Expression from the Type field and choose Create Object .
4. In the Object Creation dialog that appears, choose Formula from the Type field.
5. Enter Calculate_tax_for_low_salary in the Name field.
6. Enter Amount to be paid in the Short Text field.
7. Choose Create and navigate to object .
You are navigated to the formula builder page.

Figure 1: Formula Editor

8. Assign a result data object by choosing .


9. In the context menu, choose Select... .
10. In the Context Query dialog box that appears, select PAYABLE_TAX_AMOUNT . This is the data object that you have already created in the context of
defining a result data object for the function.
It is added as the result data object.
11. In the context menu of the formula field, choose
Insert Data Object
Select .
12. In the Context Query dialog box that appears, select GROSS_SALARY . Again, this is a data object you have already created before in the context of
defining the function's context data.
The data object gets added to the formula.
13. Choose the * button.

PUBLIC
2014 SAP AG or an SAP affiliate company. All rights reserved.

Page 4 of 7

14. Choose the Number button.


15. In the Insert dialog box that appears, enter 0.1 and choose OK .
The number appears in the Formula field.
16. Save the formula expression.
17. Create the following formula expressions for the mid and high salary segments using the above procedure.
Name of the Formula Expression

Result Data Object

Calculate_Tax_for_med_salary

Payable_Tax_Amount

Calculate_Tax_for_high_salary

Payable_Tax_Amount

Formula
(25000 EUR * 0.1) + (Gross_Salary - 25000
EUR) * 0.2
(25000 EUR * 0.1) + (75000 EUR * 0.2) +
(Gross_Salary - 100000 EUR * 0.3)

Note
When you look at the fomulas in Expert Mode , amounts will be displayed, for example, as 25000$EUR. Don't let yourself get confused by the "$EUR" part.
The salary currency is Euro (currency code EUR), while the $ sign is inserted automatically by the system as an internal separator between the number and
the currency part of the amount. This is needed for the formula to be properly parsed by the system. If the currency in the example was US Dollars, the
formula editor would display this as $USD in Expert Mode .
Next Step
Creating Value Range Expressions

1.4 Creating Value Range Expressions


Use
In this step, we define the two different income ranges (low and medium) to which the different income tax formulas will be associated. The ranges will later serve
as comparison parameters in a decision tree where a given gross salary will be compared against the ranges.

Note
It is sufficient to define only the ranges for low and medium incomes. This is because the structure of the decision tree makes it possible to implicitly define the
high income range as the negative branch for the tests against the two other ranges. The decision tree will then illustrate the simple logical thought that if a
given income is neither low nor medium, it can only be high.

Procedure
1. In the Object Manager panel, under Detail section, choose Contained Objects tab.
The Contained Objects tab page opens.
2. Choose Expression from the Type field and choose Create Object .
3. In the Object Creation dialog box that appears, choose Value Range in the Type field.
4. Enter Gross_Salary_is_low in the Name field and choose Create and navigate to object button.
The value range expression appears in the Object Manager panel.
5. Define the incoming parameter by choosing .
6. In the context menu, choose Other Context Parameter... .
7. In the Context Query dialog box that appears, select the GROSS_SALARY data object.
The data object is added as the incoming parameter for the value range expression.

Figure 1: Value Range Definition: Initial Screen

8. Enter values for the incoming parameter.


Choose is less than as the range, enter 25000 as the amount and choose EUR as the currency.

PUBLIC
2014 SAP AG or an SAP affiliate company. All rights reserved.

Page 5 of 7

Figure 2: Value Range Definition For Low Income

9. Save the value range expression.


Create the following value range expression using the above procedure.
Name of the Value Range Expression

Incoming Parameter

Values

Gross_Salary_is_Medium

Choose Gross_Salary data object.

Choose value range as is less than


Amount 100000 and EUR as the currency.

Next Step
Adding Values to the Decision Tree Expression

1.5 Adding Values to the Decision Tree Expression


Use
In this step, we will define the different branches of the decision tree object that serves as the tax calculation function's top expression.

Procedure
1. In the Object Manager panel of the application, under the Detail section, choose the Contained Objects tab.
2. In the Contained Objects tab page, choose type Function and select TAX_CALCULATOR .
The TAX_CALCULATOR function opens in the Object Manager panel.
3. Choose TAX_CALCULATION expression in the Top Expression field.
The decision tree opens in the Object Manager panel.

Figure 1: Decision Tree Definition: Initial Screen

4. Assign result data object.


1. Next to Result Data Object , choose .
2. In the context menu, choose Select...
3. In the Object Query dialog box that appears, select the PAYABLE_TAX_AMOUNT data object and choose Select .
The data object is added as a result data object.
5. Assign a root node.
We start the decision tree with a check to find out whether a given income falls into the value range we have defined for low income. To accomplish this, in
the context menu of the node, choose
Set Condition...
GROSS_SALARY_IS_LOW
The selected expression is set as the root node and two child nodes (positive and negative) appear under the root node as shown below.

Figure 2: Decision Tree Definition: Check For Low Income

6. Add conditions and results to the child node. For the first condition, a positive result indicates that the income in question falls into the range of low income.

PUBLIC
2014 SAP AG or an SAP affiliate company. All rights reserved.

Page 6 of 7

Because of that, we have to assign the corresponding tax calculation formula for low income to that child node:
1. In the context menu of the positive child node, choose
Set Result...
CALCULATE_TAX_FOR_LOW_SALARY .
The expression is added as the result of the child node.
2. In the context menu of the negative child node, we have still to decide if the income in question is medium or high. To model this decision, choose
Set Condition...
GROSS_SALARY_IS_MEDIUM .
The expression is added as the condition of the child node.
3. Similarly, add the following expressions as results to the decision tree.
CALCULATE_TAX_FOR_MED_SALARY
CALCULATE_TAX_FOR_HIGH_SALARY

Figure 3: Decision Tree Definition: Complete Definition

7. Save the decision tree.


Next Step
Simulating the Function

1.6 Simulating the Function


Kontext
In this last step, we will verify the proper functioning of the tax calculation rule by running the associated function in simulation mode and checking the calculated
result.

Vorgehensweise
1. Activate the Tax Calculator function if it is still inactive.

Note
Simulating a function is only possible if the function to be run in simulation mode is active.
2. In the Object Manager panel, choose Start Simulation .
3. In the Simulation dialog box that appears, enter 35000 in the Gross Salary field and EUR in the Currency field.
4. Under Simulation Mode section, choose Show only Result and choose Run Simulation .
The amount to be paid as tax for the gross salary appears under the Result section. For a gross salary of 35000 Euros, the business rule calculates a tax
amount of 4500 Euros.

PUBLIC
2014 SAP AG or an SAP affiliate company. All rights reserved.

Page 7 of 7

Das könnte Ihnen auch gefallen