ABAP Keyword Documentation → ABAP Programming Guidelines → Structure and Style → Alternative Spellings
Calculations
Other versions: 7.31 | 7.40 | 7.54
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
.
Rule
Use the operator format
For calculations, use the operator format with the operators
(+=
, -=
, *=
, or /=
) instead of the ABAP keyword format.
Details
Calculations with the statements ADD
, SUBTRACT
,
MULTIPLY
, and DIVIDE
do not permit expressions in the operand positions and are often more difficult to read than the corresponding operator format.
Bad Example
The following source code shows a multiplication using the statement MULTIPLY
.
MULTIPLY n1 by n2.
Good Example
The following source code shows the same example as above, but in the more compact operator format.
n1 *= n2
.