Remap Regrouping

Remap regroupings are used to add new groups to a remap. These groups do not exist in the physical data set.

The following diagrams illustrate the syntax for a remap regrouping:

<remap regrouping>

──<identifier>─┬───────────┬─<group item redescription>────────────────┤
               └─<comment>─┘

<group item redescription>

            ┌◄─────────── ; ───────────┐
── GROUP ( ─┴─┬─<remap data item>────┬─┴─┬─────┬─ ) ───────────────────►
              ├─<remap group item>───┤   └─ ; ─┘
              ├─<virtual data item>──┤
              ├─<virtual group item>─┤
              └─<remap regrouping>───┘

►─┬───────────────────────────────────────────────┬────────────────────┤
  │ ┌◄──────────────────── , ───────────────────┐ │
  └─┴─┬─/1\─┬─<occurs clause>─────────────────┬─┴─┘
      │     ├─ REQUIRED ──────────────────────┤
      │     └─<stored clause>─────────────────┤
      └─/1\─┬─ HIDDEN ────────────────────────┤
            └─ READONLY ─┬────────────────────┤
                         ├─ GIVING EXCEPTION ─┤
                         └─ NO EXCEPTION ─────┘

Explanation

The nesting structure of items within groups in a remap can be changed as explained in the following text.

New groups can be added to a remap that do not exist in the physical data set. For example:

EMP DATA SET
(LAST-NAME           ALPHA(20);
 FIRST-NAME          ALPHA(15);
 HIRE-DATE           NUMBER(7);
 DEPT                NUMBER(1);
 TITLE               ALPHA(20);
 STREET             ALPHA(20);
 CITY                ALPHA(15);
 ZIP                 NUMBER(9);
);
EMPLOYEE REMAPS EMP
(LAST-NAME;
 FIRST-NAME;
 ADDRESS GROUP
    (STREET          ALPHA(20);
     CITY            ALPHA(15);
     ZIP             NUMBER(9);
    );
);

Note that the new group ADDRESS has been added to the remap EMPLOYEE. It contains STREET, CITY, and ZIP.

New groups like ADDRESS in this example are called remap regroupings. They are not associated with existing groups in the data set.

Existing groups in the data set can be remapped using remap group items. The following example illustrates the syntactic difference between remap regroupings and remap groups:

EMP DATA SET
(LAST-NAME          ALPHA(20);
 FIRST-NAME         ALPHA(15);
 HIRE-DATE          NUMBER(7);
 DEPT               NUMBER(1);
 TITLE              ALPHA(20);
 ADDR               GROUP
    (STREET         ALPHA(20);
     CITY           ALPHA(15);
     ZIP            NUMBER(9);
    );
); 
EMPLOYEE1 REMAPS EMP
 (LAST-NAME         ALPHA(20);
  FIRST-NAME         ALPHA(15);
  HIRE-DATE          NUMBER(7);
  DEPT               NUMBER(1);
  TITLE              ALPHA(20);
  ADDRESS = ADDR     GROUP           % THIS IS A
     (STREET         ALPHA(20);      % REMAP GROUP.
      CITY           ALPHA(15);
      ZIP            NUMBER(9);
     );
 );
EMPLOYEE2 REMAPS EMP % BOTH GROUPS IN THIS REMAP
                     % ARE REMAP REGROUPINGS.
 (LAST-NAME         ALPHA(20);
  FIRST-NAME        ALPHA(15);
  HIRE-DATE         NUMBER(7);
  JOB-INFO          GROUP
     (DEPT          NUMBER(1);
      TITLE         ALPHA(20);
     );
  NEW-ADDRESS       GROUP
     (STREET        ALPHA(20);
      CITY          ALPHA(15);
      ZIP           NUMBER(9);
     );
 );

A remap group item is tied back to a group in the data set by its name. A remap group item either has the same name as the group in the data set or is associated with the original group using the <identifier> = <group item name> construct.

A remap regrouping is not tied back to any group in the data set. It must have a name that is unique within the remap to which it belongs and within the data set that is being remapped.

A distinction is made here between remap group items and remap regroupings because there are restrictions that apply to remap group items but that do not apply to remap regroupings.

If an item is not in a certain group in the data set, it cannot be in a corresponding remap group item in a remap. For example:

CUST DATA SET
(NAME                     ALPHA(20);
 BILLING-ADDR             GROUP
    (STREET               ALPHA(20);
     CITY                 ALPHA(15);
     ZIP                  NUMBER(9);
    );
 CUST-INFO                GROUP
    (CONTRACT-NO          NUMBER(9);
     LIAISON              ALPHA(20);
     PHONE                ALPHA(10);
    );
);
CUSTOMER REMAPS CUST
(NAME                     ALPHA(20);
 NEW-CUST-INFO            GROUP
    (CONTRACT-NO          NUMBER(9);
     LIAISON              ALPHA(20);
     PHONE                ALPHA(10);
     BILLING-ADDR         GROUP
        (STREET           ALPHA(20);
         CITY             ALPHA(15);
         ZIP              NUMBER(9);
       );
     );
);

NEW-CUST-INFO is a remap regrouping. It is not tied back to any group in CUST. So, it is legal to put BILLING-ADDR in NEW-CUST-INFO even though BILLING-ADDR is not in a group in the data set CUST. However, if NEW-CUST-INFO were a remap group item (for example, if it were declared as NEW-CUST-INFO = CUST-INFO), then this change would not be legal. Since remap group items represent items in the data set, they have the same restrictions as remap data items.