What does it do? An arithmetic expression expresses a calculation. The result of an arithmetic expression is a numeric value that exists in the calculation type> that is assigned to the arithmetic expression. In an arithmetic expression arith_exp>, the arithmetic operators> +>, ->, *>, />, DIV>, MOD>, or **> can be used to combine an operand operand1> with one or more operands operand2 >, operand3> ... Brackets> are also possible. The calculation is based on calculation rules> that depend on the respective calculation type. Arithmetic expressions can occur in the read positions of certain statements>, in particular on the right side of an assignment> with the assignment operator =>>. When used as the operand of the lossless operator EXACT>, an arithmetic expression can be checked for a lossless calculation>. The operand positions operand> are general expression positions>, that is, numeric data objects, built-in functions>, functional methods>, or compound arithmetic expressions can be specified. The arithmetic operators + >, ->, *>, />, DIV>, MOD>, and **> combine two adjacent operands. When the expression is evaluated, a numeric value is calculated and combined with the next adjacent operand. The priority of this combination depends on the operators> used. Each operand can be preceded by the signs +> or ->, in any order and separated by one or more blanks. The effect of a plus/minus sign is the same as specifying the expression +1 *> or -1 *> in its place, which means that a sign has the same priority as a multiplication. If functional methods> or character-like expressions> are specified as operands, they are executed from left to right and from inside to outside before the remainder of the expression is evaluated. The return values are buffered for use in the corresponding operand positions. Here, character-like processing functions> and string expressions> are only possible as arguments of description functions>.
Latest notes:
It should be ensured that the value of a data object that is also used as an operand is changed in a specified functional method. Even if such an operand is to the left of the functional method, its value will always be changed by the method before it is evaluated.
Arithmetic expressions, string expressions>, and bit expressions> cannot be combined. Built-in functions that are used as operands for arithmetic expressions can, however, contain string expressions or bit expressions as arguments.
If an arithmetic expression> is specified as an argument of one of the overloaded numeric functions>, the entire function works like an arithmetic expression.
A simple arithmetic expression +$|- literal>, which is comprised of an operator +$|->, a blank, and an unsigned numeric literal> literal>, has the same value as the corresponding numeric literal +$|-literal> prefixed directly with a plus/minus sign. However, since the expression is handled like an expression and always evaluated at runtime, the numeric literal should always be used in these cases for performance reasons.
The above rule specifying how functional methods> or character-like expressions> are evaluated might lead to unexpected results. BEGIN_SECTION SAP_INTERNAL_HINT A single functional method call, that is included by parentheses, is not handled like an arithmetic expression. END_SECTION SAP_INTERNAL_HINT NON_V5_HINTS ABAP_HINT_END
ABAP_EXAMPLE_VX5 The following program section calculates the hyperbolic sine with the Eulerian formula in the explicit calculation type decfloat34> and with the built-in function> sinh > in the implicit calculation type f> and displays the difference. ABEXA 00118 ABAP_EXAMPLE_END
ABAP_EXAMPLE_VX5 The following program demonstrates the rule specifying how functional methods> are evaluated in arithmetic expressions. The first calculation sets the variable changing> to 6 and returns the expected result of 9. The result of the second calculation is 15 and not 10 as might be expected. The functional method is called first and its result 9 is added to the changed value 6 of variable changing> and not to its initial value 1. ABEXA 01507 ABAP_EXAMPLE_END