SAP CALC EXPRESSSION - Guide



Get Example source ABAP code based on a different SAP table
  



Calculations

ABAP_BACKGROUND
In ABAP, the arithmetic operators in arithmetic expressions are used for numeric calculations. Calculation assignments with the operators +=, -=, *=, and /= are available for the basic arithmetic operations. These operator formats are accompanied by the dedicated ABAP keywords ADD, SUBTRACT, MULTIPLY, and DIVIDE.

ABAP_RULE
Use the operator format
For calculations, use the operator format with the operators (+=, -=, *=, or /=) instead of the ABAP keyword format.

ABAP_DETAILS
Calculations with the statements ADD, SUBTRACT, MULTIPLY, and DIVIDE do not allow expressions in the operand positions and are often more difficult to read than the corresponding operator format.

ABAP_EXAMPLE_BAD
The following source code shows a multiplication using the statement MULTIPLY. MULTIPLY n1 by n2.
ABAP_EXAMPLE_END

ABAP_EXAMPLE_GOOD
The following source code shows the same example as above, but in the more compact operator format. n1 *= n2.
ABAP_EXAMPLE_END