ADD-CORRESPONDING

Short Reference

Syntax

ADD-CORRESPONDING struc1 TO struc2.

Effect

This statement, which is not allowed in classes, adds structures by component. You must specify structures 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 name comparison is executed in the same way as for the MOVE-CORRESPONDING statement. For each component pair with the same name comp, internally the statement

ADD struc1-comp TO struc2-comp.

is executed and, if necessary, the required conversions are performed.

Note

This statement is not allowed in classes. It is error-prone, because - especially in complex structures - it cannot be guaranteed in a simple manner that the components of the same name actually have the data types and contents required for a numeric operation.

Example

The components x and y exist in both structures and are added. After adding, the results are stored 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.

Exceptions

Catchable Exceptions

CX_SY_ARITHMETIC_OVERFLOW

CX_SY_CONVERSION_OVERFLOW

Non-Catchable Exceptions