CORRESPONDING Phrase

The CORRESPONDING phrase (CORR) allows ADD, SUBTRACT, and MOVE operations to be performed on elementary data items of the same name if the group items to which they belong are specified.

Both identifiers following the keyword CORRESPONDING must be group items. In this discussion, these identifiers are referred to as identifier-1 and identifier-2.

A pair of data items (subordinate items), one from identifier-1 and one from identifier-2, correspond if the following conditions are true:
  • In an ADD or SUBTRACT statement, both of the data items are elementary numeric data items. Other data items are ignored.
  • In a MOVE statement, at least one of the data items is an elementary item, and the move is permitted by the move rules.
  • The two subordinate items have the same name and the same qualifiers up to but not including identifier-1 and identifier-2.
  • The subordinate items are not identified by the keyword FILLER.
  • Neither identifier-1 nor identifier-2 is described as a level 66 or 88 item, nor is the usage of either item INDEX, POINTER, or PROCEDURE-POINTER. Neither identifier-1 nor identifier-2 can be reference modified. The name of the data item must be unique after application of the implied qualifiers.
  • The subordinate items do not include a REDEFINES, RENAMES, OCCURS, USAGE IS INDEX, USAGE IS POINTER, or USAGE IS PROCEDURE-POINTER clause in their descriptions; if such a subordinate item is a group, the items subordinate to it are also ignored.

    However, identifier-1 and identifier-2 themselves may contain or be subordinate to items containing a REDEFINES or OCCURS clause in their descriptions.

  • Identifier-1 and identifier-2 can be subordinate to a FILLER item.
    For example, if two data hierarchies are defined as follows:
    05  ITEM-1 OCCURS 6 INDEXED BY X.
      10  ITEM-A PIC S9(3).
      10  ITEM-B PIC 99V9.
      10  ITEM-C PIC X(4).
      10  ITEM-D REDEFINES ITEM-C PIC 9(4).
      10  ITEM-E PIC 9(4) USAGE COMP.
      10  ITEM-F USAGE INDEX.
      10  ITEM-G PIC X(4).
    05  ITEM-2.
      10  ITEM-A PIC 99.
      10  ITEM-B PIC 9V9.
      10  ITEM-C PIC A(4).
      10  ITEM-D PIC 9(4).
      10  ITEM-E PIC 9(9) USAGE COMP.
      10  ITEM-F USAGE INDEX.
      10  ITEM-G PIC X(4).
    Then, if ADD CORR ITEM-2 TO ITEM-1(X) is specified,
    • ITEM-A and ITEM-A(X); ITEM-B and ITEM-B(X); ITEM-E and ITEM-E(X) are considered to be corresponding and are added together
    • ITEM-C and ITEM-C(X); ITEM-G and ITEM-G(X) are not included, because they are not numeric
    • ITEM-D and ITEM-D(X) are not included, because ITEM-D(X) includes a REDEFINES clause in its data description.
    • ITEM-F and ITEM-F(X) are not included, because they are defined as USAGE IS INDEX

When you use the (default) *PRTCORR compiler option or the PRTCORR option of the PROCESS statement, the compiler inserts comment lines in the compiler listing after each statement that contains the CORRESPONDING phrase. These comment lines, which print immediately before the next valid source statement, identify the elementary items that are affected within the groups named.