SAP ABAP Data Element TFMXFORMEL2 (Formula)
Hierarchy
SAP_ABA (Software Component) Cross-Application Component
   CA-FIM-FMA (Application Component) Financial Mathematics
     FIMA (Package) Financial mathematics
Basic Data
Data Element TFMXFORMEL2
Short Description Formula  
Data Type
Category of Dictionary Type D   Domain
Type of Object Referenced     No Information
Domain / Name of Reference Type TFMXFORMEL2    
Data Type CHAR   Character String 
Length 100    
Decimal Places 0    
Output Length 100    
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 Formula 
Medium 15 Formula 
Long 20 Formula 
Heading 10 Formula 
Documentation

Definition

Contains the formula as a mathematical expression with multiple variables that are connected by arithmetic operators.

Use

SAP provides the following predefined formulas in table AT30:

  • 0001: V1 * V2 + V3
  • 0002: V1 * V2 - V3 * V4
  • V1 + V3

You can also define customer-specific formulas in table AT30.

Variables

  • The variables contained in the formula can have a maximum length of 4 characters.
  • You can use a variable more than once in a formula.
  • You can use upper and/or lower case letters for variable names.
  • The variable &PRE copies the formula result from the previous period.

Arithmetic Operators

The following table shows the possible arithmetic operators: In the third column, 1 specifies the highest priority and 3 specifies the lowest priority in the calculation sequence. In a set of parentheses, calculations with high-priority operators are executed before calculations with low-priority operators

Operator    Calculation    Priority

+    Addition of operands    3

-    Subtraction of operands     3

*    Multiplication of operations    2

/    Division of operands    2

** or ^    Raise operands to a higher power    1

Parentheses

A complete arithmetic expression can be set in parenthesis. You can use an arithmetic expression that is set in parentheses as an operand in another arithmetic expression. In this case, it is calculated first.

Example

1 * 2 + 3 * 4 = 2 + 12 = 14

1 * (2 + 3) * 4 = 1 * 5 * 4 = 20

Rounding

If you want to round up or down or to the next whole number, use ROUND(<arithmetic formula>).

If you want to round up or down but not to a whole number, you the rounding function: ROUND together with the rounding unit R. This generates the following rounding types:

Rounding Type    Expression

Rounding    ROUND(<arithmetic formula>R)*R

Round down    ROUND(<arithmetic formula>R-0.5)*R

Round up    ROUND(<arithmetic formula>R+0.4999999999)*R

Numerical functions

The function ABS(arg) supplies the absolute value of the argument arg.

Example

If the reference interest rate REF is between 6.5 and 10.5, the valid interest rate is 8.5. Otherwise, you calculate the interest rate according to the arithmetic expression (8.5+REF)/2-0.125 .

For the example described above, you subtract the reference interest rate REF from the middle of the interval and check whether the absolute value of the difference is greater or less than 2.

IF ABS(8.5-REF)<=2 THEN 8.5 ELSE(8.5+REF)/2-0.125

Logical expressions as components of a conditional formula

You use the following condition to define whether a formula is executed:

  • IF <logical expression> THEN <arithmetic formula>

You use the following expression, if a condition is not fulfilled and another formula is to be used:

  • IF <logical expression> THEN <arithmetic formula> ELSE <arithmetic formula>

To define the logical expression, you can use the logical operators and comparison operators. You link the logical operators to the comparison operators.

Comparison Operator    Description

=    equals

<>, ><    does not equal

<    less than

>    greater than

<=, =<    less than or equal to

>    greater than

=>, >=    greater than or equal to

Logical Operator    Description    Priority

AND    AND link    2

OR    OR link    3

NOT    Negation    1

Example

To fulfill the condition a+3, you need to define the following if you do not want "a" to be in the interval between 6 and 10:

IF NOT (a>=6 AND a<= 10) THEN a+3

IF (a<6 OR a>10) THEN a+3

Dependencies

You can define customer-specific formulas in table AT30.

Example

History
Last changed by/on SAP  20110908 
SAP Release Created in 710