SAP ADD-CORRESPONDING ABAP Statements

Get Example source ABAP code based on a different SAP table
  


Standard SAP Help for ADD-CORRESPONDING

ADD-CORRESPONDING

Short Reference
• ADD-CORRESPONDING ABAP Statement
• TO ADD-CORRESPONDING (obsolete)

ABAP Syntax(Obsolete)ADD-CORRESPONDING struc1 TO struc2.

What does it do? This statement, which is not allowed in classes, adds structures by component. Structures must be specified for struc1 and struc2. All components of the same name in struc1 and struct2 are added in pairs and the result is assigned to the respective component of struct2.

The names are compared, as in the statement MOVE-CORRESPONDING. For each component pair with the same name comp, the statement

ADD struc1-comp TO struc2-comp. is executed, and the appropriate conversions are performed, if necessary.



Latest notes:This statement is error-prone because, particularly in
complex structures, it is not easy to check that components of the same name have the data type and content necessary for a numeric operation.



Example ABAP Coding
The components x and y exist in both
structures and are added. After the addition, the results are in struc2-x and struc2-y. DATA: BEGIN OF struc1,
x TYPE i,
y TYPE i,
z TYPE i,
END OF struc1,
BEGIN OF struc2,
a TYPE i,
b TYPE i,
x TYPE p LENGTH 8 DECIMALS 0,
y TYPE p LENGTH 8 DECIMALS 0,
END OF struc2.

...

ADD-CORRESPONDING struc1 TO struc2.



Runtime Exceptions

Catchable Exceptions
CX_SY_ARITHMETIC_OVERFLOW
Reason for error:
Overflow while adding, type I in 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 while adding
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

Return to menu