Skip to content

ABAP Keyword Documentation →  ABAP - Reference →  Obsolete Language Elements →  Obsolete Processing of Internal Data →  Obsolete Calculation Statements 

ADD-CORRESPONDING

Short Reference

Other versions: 7.31 | 7.40 | 7.54

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

  • Cause: Overflow while adding, type I in additions UNTIL or FROM ... TO
    Runtime Error: ADDF_INT_OVERFLOW
  • Cause: Overflow in arithmetic operation (type p)
    Runtime Error: BCD_OVERFLOW
  • Cause: Integer overflow while adding
    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-Catchable Exceptions

  • Cause: Access to data outside of the range specified in the RANGE addition
    Runtime Error: ADD_FIELDS_NOT_IN_RANGE
  • Cause: Invalid access to tables, strings, field references, or object references within the range specified by the addition RANGE.
    Runtime Error: ADD_FIELDS_ILLEGAL_ACCESS
  • Cause: p field does not contain the correct BCD format
    Runtime Error: BCD_BADDATA