SAP ADD SEQUENCES ABAP Statements



Get Example source ABAP code based on a different SAP table
  


• THEN UNTIL ADD (obsolete)
• TO ADD THEN UNTIL (obsolete)
• GIVING ADD THEN UNTIL (obsolete)
• ACCORDING TO ADD (obsolete)
• FROM TO ADD (obsolete)
• GIVING ADD FROM TO (obsolete)
• RANGE ADD (obsolete)

ADD, THEN, UNTIL
Short Reference

ABAP_SYNTAX_OBS
ADD ${ ${ dobj1 THEN dobj2 UNTIL dobj
${ ${TO result$} $| ${GIVING result $[ACCORDING TO sel$]$} $} $}
$| ${ dobj FROM pos1 TO pos GIVING result $} $}
$[RANGE range$].

What does it do?
These variants of the statement ADD, which are forbidden in classes, adds strings of data objects that are stored in equal distances from one another in the memory.
In the variant with THEN and UNTIL, the string is defined by the distance between the data objects dobj1 and dobj2. At all memory positions whose distances to dobj1 are multiple values of this distance (up to and including the position dobj), numeric data objects with the same technical type properties must be stored. The content of all these data objects is added. In the variant with TO, the total is added to the content of the data object result and the result is assigned to it. In the variant with GIVING, the total is directly assigned to the data object result. The data object result must be a numeric variable. If the addition ACCORDING is used, a data object of the string is added to the total only if its position in the string meets the condition in the ranges table sel . The components low and high in the ranges table expect the data type i.
In the variant with TO and FROM, the string is formed by data objects directly adjacent in the memory, whose first data object is dobj and which must all have the same numeric data type. pos1 and pos expect data objects of the type i, whose values define a subset of the string. The content of the data objects of the substring is added and assigned to the data object result. The data object result must be a numeric variable. If pos1 or pos contain negative values or if pos1 is greater than pos, the statement is not executed, and result remains unchanged.
In both variants, an uncatchable exception is raised if addresses are accessed that do not contain suitable data objects.
All data objects of the string must be within a structure. If this is not known statically in the syntax check, a structure range with the addition RANGE must be specified. If the data objects of the string are not part of the specified structure when the statement is executed, an uncatchable exception is raised.
The calculation type of the addition is, as usual, determined from the operands involved.



Latest notes:

The function of these variants of the ADD statement depends on the structure of the working memory. Memory-based operations of this type should be avoided. They are not allowed in classes and can be replaced as required by the statement ASSIGN with the addition INCREMENT .
ABAP_HINT_END



Example ABAP Coding

The components of the structure numbers specified on the selection screen are added and the total is assigned to variable sum.
ABEXA 00003
ABAP_EXAMPLE_END



Runtime Exceptions



Catchable Exceptions
CX_SY_ARITHMETIC_OVERFLOW
Reason for error:
Overflow in addition, type I in the additions UNTIL or FROM ... TO
Runtime error:
ADDF_INT_OVERFLOW
Reason for error:
Overflow in arithmetic operation (type p)
Runtime error:
BCD_OVERFLOW
Reason for error:
Integer overflow in addition
Runtime error:
COMPUTE_INT_PLUS_OVERFLOW
CX_SY_CONVERSION_OVERFLOW
Reason for error:
Overflow in arithmetic operation (type p, with specified length)
Runtime error:
BCD_FIELD_OVERFLOW

Non-catchable Exceptions
Reason for error:
Access to data outside of the range specified in the RANGE addition
Runtime error:
ADD_FIELDS_NOT_IN_RANGE
Reason for error:
Invalid access to tables, strings, field references, or object references within the range specified by the addition RANGE.
Runtime error:
ADD_FIELDS_ILLEGAL_ACCESS
Reason for error:
p field does not contain the correct <(>BCD<)> format
Runtime error:
BCD_BADDATA
ABAP_NONCAT_END

Return to menu