Definition:
Formulas define how transaction data is to be processed in order to generate plan data. Formula functions enable you to use extended mathematical functions to calculate plan data. In addition to different calculation functions, which you can use for value assignment in formulas, there is also the possibility to model complex flow structures with the formula language FOX (FOrmula eXtensions).
How to specify a record in a formula:
- You use { }-operands to access transaction data. Syntax:
{field to be changed 1, field to be changed 2, …, field t.b.c. n}
- If "key figure name" is a field to be changed, then each key figure in
a record can be addressed individually.
- If "key figure name" is not in the fields to be changed, then all key
figures of the data record will be changed according to the formula.
- Use F4-help for entering { }-operands.
How to read and write data:
- To read data, put the { }-operand on the right hand side of equations.
- To write data, put the { }-operand on the left hand side of equations.
Do not forget the "." at the end of each statement.
Example 1:
Calculate sales amount from sales quantity and a fixed price
- Field(s) to be changed: Key figure name
- Formula: {0AMOUNT} = {0QUANTITY} * 100.
- Note: If key figure is the only field to be changed, you do not need
the { } brackets: 0AMOUNT = 0QUANTITY * 100.
Example 2:
For each product copy data from the current year (2005) to the
next year (2006)
- Field(s) to be changed: Fiscal Year
- Formula: {2006} = {2005}.
- Note: You do not have to care about the product because of the
subsets ("automatic FOREACH")!
FOX Formulas – Foreach Statement
You have to define a local variable:
DATA year TYPE 0fiscyear.
Use this variable in the Foreach Statement:
FOREACH year.
{year} = {2004} * 1.05.
ENDFOR.
The values for YEAR are taken from the records in the selection of
the planning package.
Assume we have data records for year 2005 and 2006.
First loop: YEAR is replaced with 2005, system calculates
{2005} = {2004} * 1.05.
Second loop: YEAR is replaced with 2006, system calculates
{2006} = {2004} * 1.05.
Variables
Example of formula using one planning area variable and three local
variables:
DATA ZCURPER TYPE 0FISCPER.
DATA ZFCPER TYPE 0FISCPER.
DATA COUNTER TYPE I.
* Copy current period to the next 5 forecast periods
ZCURPER = VARV('PERCUR').
DO.
COUNTER = COUNTER + 1.
ZFCPER = TMVL(ZCURPER,COUNTER).
{0COPASLQTY,ZFCPER,RFC} = {0COPASLQTY,ZCURPER,ACT}.
IF COUNTER = 5.
EXIT.
ENDIF.
ENDDO.
Standard Fox Statements
Using Time Characteristics TMLV( Characteristic, Offset )
- offset: to add for example one year you would select 1 as offset
IF … ELSEIF … ENDIF.
- ELSEIF if you want to integrate several alternatives
IF … ELSE … ENDIF.
- ELSE if no condition mentioned before works
Loop Constructs
DO … ENDDO.
- Needs explicit EXIT Condition
FOREACH … ENDFOR.
- Ending, if last selected characteristic value or key figure is reached
No comments:
Post a Comment