SAP CALCULATION ASSIGNMENTS



Get Example source ABAP code based on a different SAP table
  


• += ABAP_ASSIGN_OPERATOR
• -= ABAP_ASSIGN_OPERATOR
• /= ABAP_ASSIGN_OPERATOR
• *= ABAP_ASSIGN_OPERATOR

+=, -=, *=, /=, Calculation Assignments

ABAP_SYNTAX
lhs +=
$| -=
$| *=
$| /= rhs.

What does it do?
Calculation assignment with one of the following calculation assignment operators:
addition assignment operator +=
subtraction assignment operator -=
multiplication assignment operator *=
division assignment operator /=
These assignments have the same effect as the following assignments of arithmetic expressions:
lhs = lhs + ( rhs ).
lhs = lhs - ( rhs ).
lhs = lhs * ( rhs ).
lhs = lhs / ( rhs ).
The content of lhs
gets the result of the parenthesized expression rhs added to it,
or has the result of the parenthesized expression rhs subtracted from it,
or is multiplied by the result of the parenthesized expression rhs ,
or is divided by the result of the parenthesized expression rhs,
and the result is assigned to lhs. The calculation type is determined accordingly.
The following applies to the operands lhs and rhs:
lhs is a result position and numeric:
Variables and
Writable expressions
can be specified.
rhs is a numeric expression position and numeric:
Data objects
Constructor expressions
Arithmetic expressions
Table expressions
Functions
can be specified. Type inference with the character # is not currently possible in constructor expressions. Character-like expressions and bit expressions cannot be specified.
Division by the value 0 is undefined and raises a catchable exception. The only situation where division by 0 does not raise an exception is if the dividend is also 0. Here, the result is set to 0.



Latest notes:

Apart from data objects, calculation assignments also allow expressions in the operand positions. This makes them more powerful than the statements ADD, SUBTRACT, MULTIPLY, DIVIDE, and also makes them obsolete.
No inline declarations are possible for lhs .
Calculation assignments can currently only be specified as standalone statements. They are not possible in other expressions, such as after NEXT in the reduction operator REDUCE.
See also the concatenation assignment operator ( = ).
NON_V5_HINTS
ABAP_HINT_END

ABAP_EXAMPLE_VX5
The variable n has the value 1.50 after the calculation assignments.
ABEXA 00845
ABAP_EXAMPLE_END