sapdev logo background
sapdev logo sapdev logo
Comments

SAP CALC EXPRESSSION GUIDL documentation, setup help and example usage



Return to SAP documentation index


GUIDELINE 4.20

Calculations

ABAP_BACKGROUND
In ABAP, the arithmetic operators
in arithmetic expressions are used for numeric calculations. Alongside the operand format, the dedicated ABAP keywords ADD , SUBTRACT , MULTIPLY and
DIVIDE are also used for the basic arithmetic operations.

ABAP_RULE
Using Operator Format
For calculations, use the operator format with the equals sign (=) instead of the ABAP keyword format.

ABAP_DETAILS
Calculations with the statements ADD , SUBTRACT ,
MULTIPLY , and DIVIDE are often more difficult to read than the corresponding operator format. Calculations other than the basic arithmetic operations cannot be expressed by ABAP keywords in any case.

Exception
The command format allows the use of
chained statements , which can be useful in these special cases:
ADD increment TO: sum_individual,
sum_total.
If arithmetic operations are in the form a = a + 1 , where the target variable and one of the operands are identical, using the statements ADD , SUBTRACT and so on has the advantage of being easier on the eye, especially when the name of the target variable is relatively long:
SUBTRACT 1 FROM reference- structured_attribute-component.
It is immediately clear to the observer that the value of the specified variables is reduced by one. This may not be the case for the operator format, if it is not straightaway obvious that the target variable and one of the operands are identical. In such cases you can and should ignore the above rule. The primary concern is the readability of the source code.

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 = n1 * n2 .
Documentation extract taken from SAP system, � Copyright SAP AG. All rights reserved




CALCULATION_TYPE_GLOSRY
CALENDAR_DATE_GLOSRY




comments powered by Disqus