CORRESPONDING phrase in COBOL

MOVE CORRESPONDING:

Quite often it is required to move some of the data items of one group to some other data items in another group. If the names of the corresponding data items of the two groups are distinct, then for each data item, a separate MOVE verb should be used. However, if the corresponding data items of both the records have identical names, then instead of using a separate MOVE statement, just one MOVE statement with the CORRESPONDING option can be used.

ADD and SUBTRACT CORRESPONDING:

The CORRESPONDING option can also be used with the ADD and SUBTRACT verbs.

GENERAL RULES CONCERNING CORRESPONDING OPTION:

The following rules should be observed when the CORRESPONDING option is used.

i. Identifier-1 and identifier-2 in all cases must refer to group items i.e., these identifiers must not be data items with level numbers 66, 77 or 88.

ii. Data items in identifier-1 and identifier-2 take part in the specified operation (MOVE, ADD or SUBTRACT) only when they have the same data name and same qualifiers up to but not including identifier-1 and identifier-2.

iii. In the case of ADD or SUBTRACT CORRESPONDING only numeric data items are considered for addition or subtraction respectively. This means that data items other than numeric are not considered for the arithmetic operations even though they may have identical names in the two groups named in identifier-1 and identifier-2.

iv. All data items subordinate to identifier-1 and identifier-2 with level numbers 66 or 88 or containing a REDEFINES or OCCURS clause, are ignored for the operation. Identifier-1 and identifier-2 may, however, have a REDEFINES or OCCURS clause or may be subordinate to data items having a REDEFINES or OCCURS clause.

v. FILLER data items are ignored.

vi. CORRESPONDING items can have different locations within the group and the field sizes can also be different.