SUBTRACTCORRESPONDING
Basic form
SUBTRACTCORRESPONDING rec1 FROM rec2.
Effect
Interprets rec1 and rec2 as field strings.
If, for example, rec1 and rec2 are tables, executes the
statement for their header lines.
Searches for all subfields which occur both in rec1 and
rec2 and then generates, for all relevant field pairs
corresponding to the component fields ni , statements of the form

SUBTRACT rec1ni FROM rec2ni.
The other fields remain unchanged.
With complex structures, the full names of the field pairs must be
identical.
Example

DATA: BEGIN OF PERSON,
NAME(20) VALUE 'Paul',
MONEY TYPE I VALUE 5000,
END OF PERSON,
BEGIN OF PURCHASES OCCURS 10,
PRODUCT(10),
MONEY TYPE I,
END OF PURCHASES.
PURCHASESPRODUCT = 'Table'.
PURCHASESMONEY = 100.
APPEND PURCHASES.
PURCHASESPRODUCT = 'Chair'.
PURCHASESMONEY = 70.
APPEND PURCHASES.
LOOP AT PURCHASES.
SUBTRACTCORRESPONDING PURCHASES FROM PERSON.
ENDLOOP.
The value of PERSONMONEY is now 4830. The above
SUBTRACTCORRESPONDING statement (executed twice here) is
equivalent to:

SUBTRACT PURCHASESMONEY FROM PERSONMONEY.
Note
All fields of the same name are subtracted, whether they
are numeric or not. Here, the conversions performed are the same as
with SUBTRACT and the same runtime
errors can occur.
Related
SUBTRACT
MOVECORRESPONDING
ADDCORRESPONDING
MULTIPLYCORRESPONDING
DIVIDECORRESPONDING
Index
© SAP AG 1996