ABAP Keyword Documentation → ABAP − Reference → Obsolete Language Elements → Obsolete Processing of Internal Data → Obsolete Calculation Statements
ADD
Other versions: 7.31 | 7.40 | 7.54
Obsolete Syntax
ADD dobj1 TO dobj2.
Effect
This statement has the same effect as the statement
The content of dobj1
is added to the content of dobj2
and the result is assigned to dobj2
. The data objects dobj1
and dobj2
have to be numeric. Only data objects can be specified, no calls or other expressions. The
calculation type is determined like an arithmetic expression.
Note
The statement shown here has been replaced by
calculation assignments with the operator +=
in which the operands can also be specified as expressions.
Example
The variable result_old
has the value 10 after the calculation statements. The syntax for the
calculation assignment with the same meaning is also shown.
DATA result_old TYPE i.
DO 10 TIMES.
ADD 1 TO result_old.
ENDDO.
DATA(result_new) = 0.
DO 10 TIMES.
result_new += 1.
ENDDO.
ASSERT result_old = result_new.
Exceptions
Handleable Exceptions
CX_SY_ARITHMETIC_OVERFLOW
-
Cause: Overflow in arithmetic operation (type
p
)
Runtime error:BCD_OVERFLOW
-
Cause: Integer overflow in addition
Runtime error:COMPUTE_INT_PLUS_OVERFLOW
CX_SY_CONVERSION_OVERFLOW
-
Cause: Overflow in arithmetic operation (type
p
, with specified length)
Runtime error:BCD_FIELD_OVERFLOW
Non-Handleable Exceptions
-
Cause:
p
field does not contain the correct BCD format
Runtime error:BCD_BADDATA