ABAP Keyword Documentation →  ABAP − Reference →  Obsolete Language Elements →  Obsolete Calculation Statements → 

ADD-CORRESPONDING  Syntax Diagram

Short Reference

Obsolete Syntax

ADD-CORRESPONDING struc1 TO struc2.

Effect

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.

Note

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

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.

Exceptions

Catchable Exceptions

CX_SY_ARITHMETIC_OVERFLOW

CX_SY_CONVERSION_OVERFLOW

Non-Catchable Exceptions