SUBTRACT-CORRESPONDING struc1 FROM struc2.
This statement is not allowed in an ABAP Objects context. See Operations based on pairs of identically-named fields not allowed.
struc1 and struc2
are regarded as structures, that is, if they are, for example, internal tables with header lines, the
statement will apply to the header lines, not the table body.
The statement looks for fields that
occur with the same name in both
struc1 and struc2.
For each pair of identically-named fields ni, the system generates a
SUBTRACT struc1-ni FROM struc2-ni.
statement. Components that do not have a corresponding field in the other structure remain unchanged.
In a complex structure, the full names of the field pairs must be identical.
DATA: BEGIN OF PERSON,
NAME(20)
VALUE 'Paul',
MONEY TYPE I VALUE 5000,
END OF PERSON.
TYPES: BEGIN OF PURCHASE,
PRODUCT(10),
MONEY TYPE I,
END OF PURCHASE.
DATA: PURCHASES TYPE TABLE OF PURCHASE,
PURCHASES_WA LIKE LINE OF PURCHASES.
PURCHASES_WA-PRODUCT
= 'Table'.
PURCHASES_WA-MONEY = 100.
APPEND PURCHASES_WA TO PURCHASES.
PURCHASES_WA-PRODUCT
= 'Chair'.
PURCHASES_WA-MONEY = 70.
APPEND PURCHASES_WA TO PURCHASES.
LOOP
AT PURCHASES INTO PURCHASES_WA.
SUBTRACT-CORRESPONDING PURCHASES_WA FROM PERSON.
ENDLOOP.
The value of
PERSON-MONEY is now 4830. The above SUBTRACT-CORRESPONDING statement, executed twice, is the equivalent of the following statement:
SUBTRACT PURCHASES_WA-MONEY FROM PERSON-MONEY.
The system performs the subtraction on all pairs of identically-named fields, not just numeric ones.
The same conversions are performed as apply to the SUBTRACT.
Catchable Exceptions
CX_SY_ARITHMETIC_OVERFLOW
CX_SY_CONVERSION_OVERFLOW
Non-Catchable Exceptions
Cause: P field does not contain correct BCD
SUBTRACT, MOVE-CORRESPONDING,
ADD-CORRESPONDING,
MULTIPLY-CORRESPONDING,
DIVIDE-CORRESPONDING
Arithmetic Calculations