Fox Formula in SAP BI-Integrated Planning: Applies To
Fox Formula in SAP BI-Integrated Planning: Applies To
Fox Formula in SAP BI-Integrated Planning: Applies To
Planning
Applies to:
This applies to SAP BI 7.X. For more information, visit the EDW homepage.
Summary
This document contains method of implementing a FOX (Formula extension) in SAP BW Integrated
Planning. It also covers the method of debugging the FOX code and using it in the Front End (WAD).
Author:
Author Bio
Anupama is working as a Senior Systems Engineer with Infosys Technologies Ltd. He has a good
experience in the SAP BI technology and have been involved in the implementation and execution of BW/BI
Projects.
Table of Contents
Introduction: .................................................................................................................................................. 3
How to start with Fox Formula: ...................................................................................................................... 3
Planning Function Types: .............................................................................................................................. 4
Standard planning function: ....................................................................................................................... 4
Formula extension (FOX):.......................................................................................................................... 4
Custom planning function: .......................................................................................................................... 4
Different program elements of FOX and there use: ........................................................................................ 5
Step by step procedure for creation of planning function using Formula extension (FOX):.............................. 6
Step 1 - InfoProvider Creation: ................................................................................................................... 6
Step 2 Aggregation Level Creation: ......................................................................................................... 7
Step 3 Filter Creation: ............................................................................................................................. 8
Step 4 Creation of Planning Function: ..................................................................................................... 9
Step 5 FOX code: ................................................................................................................................... 9
Step 6 Planning Sequence Creation:..................................................................................................... 14
Debugging the FOX (Formula extension):.................................................................................................... 15
Step 1 Putting break point: .................................................................................................................... 15
Step 2 Execution of Program: ............................................................................................................... 15
Step 3 Step by step debugging: ............................................................................................................ 16
Front end development to use the FOX formula in reports: .......................................................................... 17
Step 1 Creation of query: ...................................................................................................................... 17
Step 2 Web Template creation: ............................................................................................................. 18
Step 3 Addition of Button Group:........................................................................................................... 18
Conclusion: ................................................................................................................................................. 21
Related Content .......................................................................................................................................... 22
Copyright ....................................................................................................... Error! Bookmark not defined.
Introduction:
BI Integrated Planning provides business experts with an infrastructure for realizing and operating planning
scenarios or other applications. Planning covers a wide range of topics from simple data entry to complex
planning scenarios.
Business planning allows developers to create and operate planning scenarios or other applications.
Business planning provides the following planning tools for these purposes:
BI Integrated Planning, a solution that is completely integrated into the BI system
BW-BPS (Business Planning and Simulation)
SAP Business Intelligence Integrated Planning (SAP BI-IP) provides the standard allocation formulas which
are used for basic allocation requirement. For more complex business cases, standard formulas are not able
to fulfill the requirement and in this case FOX which comes with SAP BI-IP can fulfill the
complex development requirements.
Start
or
Partially writable MP
Create Query
Create Filter
for
Step by step procedure for creation of planning function using Formula extension
(FOX):
Step 1 - InfoProvider Creation: The first step is the creation of Real Time InfoCube. We can also use a
partially writable MultiProvider depending on the requirement. The partially writable MultiProvider is created
by building the MultiProvider on at least one Real time cube and other InfoProviders. We go for MultiProvider
in scenarios where we want to do reporting on more than one InfoProvider say on actuals and on planning.
MultiProvider reduces the frequency of errors and granularity of the planned and reported data is the same.
The InfoProvider created can be viewed in the planning Modeler. For this we need to open the Modeler
which can be accessed through the transaction code RSPLAN. Once we are in the transaction clicking on
the start Modeler takes us to the planning modeler. The modeler opens up in a web page. Once the modeler
opens we can view our required InfoProvider by giving the technical name of the InfoProvider.
Step 2 Aggregation Level Creation: The next step is creation of Aggregation Level. The aggregation
level is a subset of the InfoProvider containing the required characteristic and KeyFigures. The data in
aggregation level gets aggregated for the characteristic which are not selected in the aggregation Level.
Step 3 Filter Creation: The next step is creation of filter on the aggregation level. The filter is created by
providing a technical name and description for the filter and then selecting the aggregation level on which it
should be created. Then we can select one or more characteristics(as required) on which we want to restrict
the data as filter characteristics. The filter helps us to restrict the data based on variable entry (at runtime) or
direct restriction on characteristic values. The filter can be a restriction on a single value or multiple values.
Step 4 Creation of Planning Function: Once the filter is created we go on to create the Planning
Function on our aggregation level. For writing a FOX code we select the planning function type Formula,
provide a technical name and description for the planning function and select the required aggregation level.
This Formula planning function type enables us to write FOX(Formula Extension) code.
Step 5 FOX code: The next step is writing the FOX code. Before writing the code we need to select the
characteristic from To Character usage for the characteristic which logically belong together and the
characteristic values for which we want the KeyFigure changed. This helps in the Block formation.
Technically, every planning function that is executed is called internally more than once. For this purpose,
the data to be processed selected by filter is divided into blocks. The planning function is called separately
for each block.
If this selection is not done the block levels increases, thus the records we require for our functionality might
fall in different blocks.
The FOX code is as follows. There are five different type of syntax covered in this code:
1. Data declaration (local Variables) The data declaration is done as standard type like integer, string
or it can be declared as type of the available characteristic.
2. Information derivation (Variables) The variable function (VARV) helps us to get the 1st value of the
variable (global) entered in the Variable screen.
3. Calculations (Operators) The simple addition command helps us in getting the sum of two months
of data.
In case of addition we are using parameters within brackets. This is used to specify characteristics
for which we want to change the KeyFigures. In the example shown below we want to add the values
of a particular Customer account group SBUC for two months 200906 and 200907 for all values of
Customer Code. These parameters contain the characteristics selected in the To Character Usage
tab, in the same order it is selected there. The parameters within brackets have to be used every
time some functionality is performed on any KeyFigure values.
4. Conditional statement The conditional statement if-else is used to execute a block of statement
only if some condition is true. In the example below two months of data is summed, based whichever
is greater some assignments are done.
5. Characteristic and attribute The ATRV command helps us to derive the attribute value for
characteristic IC_CNTYCD.
DATA Z_ADD TYPE I.
Data declaration of type Integer
*USE ATTRIBUTES
Z_CUNTRYCD = ATRV(IC_CNTYCD,Z_CUSCODE).
IF Z_CUNTRYCD = 'IN'.
{0DEB_CRE_LC, SBUC, 200905,0000000003} = Z_ADD - 100.
ENDIF.
The second FOX code is as follows. The syntax covered here are:
1. Loop The loop statement helps us to loop at all the data based on some local variable. In the
example shown we loop through all the data based on Calendar month. The other type of loop
possible in FOX is Do loop.
2. Mathematical function There are many mathematical function possible in FOX like Sine, Truncate
etc. The ROUND command helps us to round off a value to the required no of places. Here we are
rounding off to 0 decimal places.
3. Calling Function Module We can call function module in FOX code also. For this we need to create
a Function Module in the transaction code SE37 with the Import and Export parameters we require.
Then we go to transaction SM31 and make an entry for the Function Module in the table
RSPLF_FDIR. Once this is done the Function Module is available to be called in the FOX code. The
import and Export parameters should be in sync with the DataType supported by FOX. In the
example shown below we call ZIP_TEST function module exporting Z_CUSCODE value and import
Z_IC_GEOSEG value. The imported value is used further in the code.
4. Finance Functions The finance function covers some commonly used finance functions like
currency translation, discount calculation etc. Here is an example how to calculate the discount of
10% for 2 years.
DATA Z_ADD TYPE F.
DATA Z_CUSCODE TYPE IC_CUSCOD.
DATA Z_CALMONTH TYPE 0CALMONTH.
DATA Z_IC_GEOSEG TYPE IC_GEOSEG.
DATA Z_ROUND TYPE I.
DATA Z_ROUND1 TYPE F.
DATA Z_DISC TYPE F.
Z_ROUND1 = ROUND(Z_ADD,0).
{IA_TDSO, SBUC, Z_CALMONTH,Z_CUSCODE} = Z_ROUND1.
ENDFOR.
End of Loop
Step 6 Planning Sequence Creation: The next step is creation of planning sequence. Planning
function is used to bundle different planning functions (from the same aggregation level or different
aggregation level) together. For creation of Planning Sequence we need to give a Technical name and
description for the planning function. Then we need to select Add Step to planning Function if we want
to execute some planning Function or we select Add step to Input Template if we just want to view data
in an aggregation level based on some filter. In case we select Add Step to planning Function we need
to select the aggregation level, Filter and Planning Function. Else if we select Add step to Input
Template we just need to select the Aggregation level and the filter.
The input template of the planning sequence gives the initial view of the data based on the filter while the
Planning function step on execution modifies the data based on the functionalities performed by the
selected Planning Function. The Planning function step can be executed by pressing Execute or
Execution with trace. The Execute button executes the planning sequence or the selected step and
modifies the data which can be saved by pressing the Save button. In case we press Execution with
trace, we get detailed information on which all data records were changed. And thus we can do a
detailed analysis of the Planning Function.
The variable input value needs to be provided before execution of planning sequence if the variable is a
mandatory variable or its value is used in the planning function.
Step 2 Execution of Program: Then we go to the transaction code SE38 and execute the program
RSPLS_PLSEQ_EXECUTE, providing the planning sequence name there. We can save the details as
variants for further use. We can also save the data after the planning sequence execution. This can be
done by checking the checkbox shown below. If the checkbox is checked once the planning sequence
code is executed the changed data gets saved in the planning InfoProvider.
Step 3 Step by step debugging: Now the FOX code can be debugged. And the exact step by step
functionality can be checked for.
Step 2 Web Template creation: Next the Web Template is created with the above created Input
Ready query. It is not necessary to set the data provider initially; it can be set dynamically at runtime
also. The analysis web item of the Web template enables us to view the query data and manipulate the
data according to our requirement.
Step 3 Addition of Button Group: A button group is also inserted in the web item to implement the
planning function and to save data. We can unable our planning function with other Web Items as well.
The settings for the button group are as follows:
The command EXEC_PLANNING_SEQ is selected and the required planning sequence is selected in it.
To save data
WAD output with the button group and the analysis item after the Planning Sequence is executed:
Conclusion:
Using FOX (Formula extension) we can handle complex functionalities which cannot be handled by the
standard planning function types provided by SAP. The planning data gets modified when the planning
sequence containing the FOX planning function is executed. Implementing the FOX formula is complex as
compared to the standard planning function types, so it should be used only when the required functionalities
cannot be achieved by standard planning function types.
Related Content
www.sdn.sap.com
help.sap.com
http://help.sap.com/saphelp_nw70/helpdata/en/44/21de357641648fe10000000a1553f7/content.htm
For more information, visit the EDW homepage.