SAP ABAP Data Element UPC_Y_FLINE (Formula Line)
Hierarchy
SAP_BW (Software Component) SAP Business Warehouse
   BW-PLA-BPS (Application Component) Business Planning and Simulation
     UPC (Package) SEM-BPS: General Functions
Basic Data
Data Element UPC_Y_FLINE
Short Description Formula Line  
Data Type
Category of Dictionary Type D   Domain
Type of Object Referenced     No Information
Domain / Name of Reference Type TEXT60    
Data Type CHAR   Character String 
Length 60    
Decimal Places 0    
Output Length 60    
Value Table      
Further Characteristics
Search Help: Name    
Search Help: Parameters    
Parameter ID   
Default Component name    
Change document    
No Input History    
Basic direction is set to LTR    
No BIDI Filtering    
Field Label
  Length  Field Label  
Short 10 Form. line 
Medium 15 Formula 
Long 20 Formula line 
Heading 55 Formula 
Documentation

Formula Calculation

Overview of the Scope of the Functions

The planning function of type Formula Calculation provides you with a simple programming language for manipulating transaction data. It includes parts that can be found in a number of macro languages for business applications:

Commands that change transaction data using operators and functions, such as: ERLOES = ABSMG * PREIS.

One form of the conditional command, such as: IF expression. expression. ENDIF.

General loop constructions, such as.: DO. command. IF expression. EXIT. ENDIF. ENDDO.

A special loop construct FOREACH, which iterates over all the characteristic values of one or more characteristics in the transaction data A precise explanation of the construct can be found in a separate section below.

A DATA command to define auxiliary variables.

A commenting option. Comments begin with a'*' at the start of the line.

Internal Data Objects and Addressing

Normally a formula is executed more than once. The user executes a planning function by selecting a planning package and a parameter group. This package is divided into smaller data objects of transaction data. If a formula needs reference data, these data objects are also formed directly from this reference data. Note: If no data objects can be formed, a formula is not executed. The only difference between the data objects is in the characteristic values of the characteristics to be changed. The values of the other characteristics are the same. If no characteristics to be changed are selected, the formula is executed once for each transaction data record. From the point of view of the system, the planning function is therefore called once for each data object, and not once for each package. Each key figure value in the data object can now be addressed uniquely by entering the characteristic values of the characteristic to be changed and the key figure name, and can be changed using functions. To understand how a formula works, it could be useful to define a layout in which all the characteristics to be changed are in the lead columns and the remaining characteristics are in the header. The formula is then processed for all combinations. The current package does not contain the reference data that can be referred to in the formulas. You therefore might have to extend the layout by columns with reference data. Tip: Limit the values in the package relating to the characteristics in the formula that are not to be changed as much as possible so that few data objects are created.

In practice, certain functions are always executed simultaneously for all or most of the key figures. For a large number of key figures, it could be cumbersome to write down the same equation for each key figure. For this reason, there are two options for expressing the key figure reference in a formula:

You make no specifications about key figures. In this case the system executes the calculation described by the formula for all the key figures of the planning level. For example, you can write a formula for copying version 001 to version 002 as follows: { 002 } = { 001 }.

You explicitly define the key figures for which the calculation should be made. To do so, you include the generic entry "key figure name" in the list of fields to be changed and specify the technical name of the key figure to be calculated in the formula operators. To execute the example given (copying between versions) for the key figure ERLOES only, write for example{ ERLOES, 002 } = { ERLOES, 001 }.

Reference Data

There are two options if you want to access reference data in the formulas: You make the field because of which the reference data of the data of the active planning package differ as the field to be changed, for example, version technical name 0VERSION. You write the operands as follows: { ERLOES, 002 } = { ERLOES, 001 }. The other option is to explicitly address the reference data. To do so, you enter the name of the characteristic and the value in the operand: { ERLOES } = { ERLOES | 0VERSION = 001 }. In the active planning package, the example includes data in version 002. The formula is executed for each data record of the current planning package. As there are no fields to be changed, the data objects consist of one record. The difference between the two variants is not only syntactic. The creation of the data objects is also controlled, which also defines how often the formula is executed. For the notation { ERLOES, 002 } = { ERLOES, 001 }, this is as follows: If there is no data yet in version 002, the internal data objects are created from the data of version 002 and also of version 001. When executing the formula, data is created in version 002. This notation is intended for formulas that want to create new data from reference data. For the notation { ERLOES } = { ERLOES | 0VERSION = 001, the formula will only run for records in version 002 as it cannot be determined from the formula how the records from version 001 are to be transformed into records from version 001. If there are no records available, the formula is not run. No records are created. The syntax is intended for formulas that need reference data to evaluate existing data.

Example: The transaction data is as follows:

0VERSION    0COSTCENTER    ERLOES

001    4711    3

001    0815    2

002    4711    9

Result of: { REVENUE, 002 } = { REVENUE, 001 }.

0VERSION    0COSTCENTER    ERLOES

001    4711    3

001    0815    2

002    4711    3

001    0815    2

Two data objects are formed.

0COSTCENTER   

4711   

0815   

Result of: { ERLOES } = { ERLOES | 0VERSION = 001 }.

0VERSION    0COSTCENTER    ERLOES

001    4711    3

001    0815    2

002    4711    3

Data Objects

0VERSION    0COSTCENTER   

002    4711   

Before executing the parameter group it is decided which reference data is required based on the formula. The original selection is enhanced for selecting reference data. Assume that only data of version 002 is available in the planning package. Based on the formula line { ERLOES, 002 } = { ERLOES, 001 }, the selection is enhanced with the value version 001. Unfortunately it is not always possible to decide what reference data is required before starting a planning function of type Formula. If this is the case, the selection is deleted. Cases where this can occur:

Using the TMVL function to change the value of a time characteristic

Using the ATRV or ATRVT functions to read attribute values

Call of Function Modules

The selection is always only deleted if the events of the function are used to address reference data.

DATA FISCPER TYPE 0FISCPER.

DATA ACTPER TYPE 0FISCPER.

ACTPER = VARV( AKTPERIO ).

FISCPER = ACTPER.

FISCPER = TMVL( FISCPER , -12 ).

{ ERLOES, ACTPER } = { ERLOES, FISCPER }.

In the example, first the formula variable ACTPER is filled from the global variable ACTPERIO. This value is then assigned to variable FISCPER. The value of ACTPER is then reduced by 12 using the TMVL function. Finally, the value of the REVENUE key figure in the FISCPER period is assigned to the value of the REVENUE key figure in the ACTPER period.

Conditions

Conditions that are not marked as to be changed can be selected as characteristics for conditions. Selection conditions can be specified for these characteristics. A formula is only calculated if the selection conditions for the internal data object are satisfied. Here, too, "key figure name" like the other characteristics of the level, can be selected for conditions. If conditions are set for the field "key figure name" , formulas are only calculated for those key figures that satisfy the selection conditions.

Formula or Exit: When to Use Which Function Type?

In addition to the formula calculation, you can also create planning functions of type Exit in order to manipulate transaction data using a programming language. Weigh up the following points to decide for one function type or the other:

Planning functions of type Formula are easy to learn and do not require a high level of effort. Ideally we picture an end-user in controlling who can already use an algorithmic programming language or a macro language and can solve the majority of problems with the formula language.

Planning functions of type Exit must therefore always be written when you require features that were not previously available. Example:

History
Last changed by/on SAP  20130604 
SAP Release Created in