Function
The RENAMES clause permits alternative, possibly overlapping, groupings of elementary data items. This clause assigns a new name to an item or items established by a record description. Unlike REDEFINES, the RENAMES clause does not redefine existing data descriptions but merely allows data to be accessed and/or grouped under alternative names while maintaining the previously defined data descriptions.
Format
66 data-name-1 RENAMES data-name-2 [ {THRU | THROUGH} data-name-3 ]
(The level number 66 and data-name-1 are not part of the RENAMES clause, and are shown only to improve clarity.)
Syntax rules
All entries of the RENAMES clause which refer to data items within a given logical record must immediately follow the last data description entry of the associated record description entry.
data-name-2 must precede data-name-3 in the record description. After each redefinition, the beginning point of the area described by data-name-3 must logically follow the beginning point of the area defined by data-name-2.
data-name-2 and data-name-3 must be the names of elementary items or groups of elementary data items in the associated logical record, and cannot be the same data-name.
The beginning of the area defined by data-name-3 must not lie to the left of the beginning of the area defined by data-name-2. The end of the area defined by data-name-3 must lie to the right of the end of the area defined by data-name-2. Hence, data-name-3 cannot be subordinate to data-name-2. Neither data-name-2 and data-name-3 nor the data that lies between them may be of the class “object” or “pointer”. Neither data-name-2 nor data-name-3 may come from a type description entry.
None of the data items within the area of data-name-2 and data-name-3, when specified, may have a variable size as described in the OCCURS clause (see "OCCURS clause" with DEPENDING ON phrase).
data-name-1 cannot be used as a qualifier and can be qualified only by the names of the associated 01-level, SD, or FD entries.
data-name-2 and data-name-3 may be qualified.
Neither data-name-2 nor data-name-3 may contain an OCCURS clause in its data description entry, nor may it be subordinate to a data item which contains an OCCURS clause in its data description entry.
The RENAMES clause may neither refer to another 66-level entry nor to a 77-level, 88-level, or 01-level entry.
The RENAMES clause may not be specified within a type description entry.
The RENAMES clause may not be specified in the record description entry of a file with organization XML.
General rules
More than one RENAMES clause may be written for the same logical record.
data-name-1 specifies an alternative definition for one or more data items.
data-name-2 or data-name-3 specifies the data item(s) to be renamed.
When data-name-3 is specified, data-name-1 is a group item that includes all elementary items:
starting with data-name-2 (if this is an elementary data item); or starting with the first elementary item within data-name-2 (if this is a group item).
concluding with data-name-3 (if this is an elementary data item); or concluding with the last elementary item within data-name-3 (if this is a group item).
If data-name-3 is not specified, then data-name-2 may be either a group item or an elementary item. If data-name-2 is a group item, data-name-1 is treated as a group item; if data-name-2 is an elementary item, data-name-1 is treated as an elementary data item.
Example 7-26
The following example shows how a RENAMES clause may be used in an actual program:
01 INPUT-RECORD. 02 ARTICLE-1. 03 ARTICLE-NO PIC 99. 03 PRICE PIC 9999. 02 ARTICLE-2. 03 ARTICLE-NO PIC 99. 03 PRICE PIC 9999. 02 ARTICLE-3. 03 ARTICLE-NO PIC 99. 03 PRICE PIC 9999. 66 ART-ONE RENAMES ARTICLE-1. 66 ART-TWO RENAMES ARTICLE-1 THRU ARTICLE-2. 66 ART-THREE RENAMES ARTICLE-1 THRU ARTICLE-3.
In this case, each reference to ART-ONE would access group item ARTICLE-1; each reference to ART-TWO, the group items ARTICLE-1 and ARTICLE-2; each reference to ART-THREE, the group items ARTICLE-1, ARTICLE-2 and ARTICLE-3.