REDEFINES clause
The REDEFINES clause allows you to use different data description entries to describe the same computer storage area.
(level-number, data-name-1, and FILLER are not part of the REDEFINES clause, and are included in the format only for clarity.)
When specified, the REDEFINES clause must be the first entry following data-name-1 or FILLER. If data-name-1 or FILLER is not specified, the REDEFINES clause must be the first entry following the level-number.
- data-name-1, FILLER
- Identifies an alternate description for the data area identified
by data-name-2; data-name-1 is
the redefining item or the REDEFINES subject.
Neither data-name-1 nor any of its subordinate entries can contain a VALUE clause.
- data-name-2
- Identifies the redefined item or the REDEFINES object.
The data description entry for data-name-2 can contain a REDEFINES clause.
The data description entry for data-name-2 cannot contain an OCCURS clause. However, data-name-2 can be subordinate to an item whose data description entry contains an OCCURS clause; in this case, the reference to data-name-2 in the REDEFINES clause must not be subscripted.
Neither data-name-1 nor data-name-2 can contain an OCCURS DEPENDING ON clause.
data-name-1 and data-name-2 must have the same level in the hierarchy; however, the level numbers need not be the same. Neither data-name-1 nor data-name-2 can be defined with level number 66 or 88.
data-name-1 and data-name-2 can each be described with any usage.
Redefinition begins at data-name-1 and ends when a level-number less than or equal to that of data-name-1 is encountered. No entry that has a level-number numerically less than those of data-name-1 and data-name-2 can occur between these entries. In the following example:
05 A PICTURE X(6).
05 B REDEFINES A.
10 B-1 PICTURE X(2).
10 B-2 PICTURE 9(4).
05 C PICTURE 99V99.
A
is the redefined item, and B
is
the redefining item. Redefinition begins with B
and
includes the two subordinate items B-1
and B-2
.
Redefinition ends when the level-05 item C
is encountered.
If
the GLOBAL clause is used in the data description entry that contains
the REDEFINES clause, only data-name-1 (the redefining
item) possesses the global attribute. For example,
in the following description, only item B
possesses
the GLOBAL attribute:
05 A PICTURE X(6).
05 B REDEFINES A GLOBAL PICTURE X(4).
The EXTERNAL clause must not be specified in the same data description entry as a REDEFINES clause.
If the redefined data item (data-name-2) is declared to be an external data record, the size of the redefining data item (data-name-1) must not be greater than the size of the redefined data item. If the redefined data item is not declared to be an external data record, there is no such constraint.
The following example shows that the redefining item, B
,
can occupy more storage than the redefined item, A
.
The size of storage for the REDEFINED clause is determined in number
of bytes. Item A
occupies 6 bytes of storage and
item B
, a data item of category national, occupies
8 bytes of storage.
05 A PICTURE X(6).
05 B REDEFINES A GLOBAL PICTURE N(4).
One or more redefinitions of the same storage area are permitted. The entries that give the new descriptions of the storage area must immediately follow the description of the redefined area without intervening entries that define new character positions. Multiple redefinitions can, but need not, all use the data-name of the original entry that defined this storage area. For example:
05 A PICTURE 9999.
05 B REDEFINES A PICTURE 9V999.
05 C REDEFINES A PICTURE 99V99.
Also, multiple redefinitions can use the name of the preceding definition as shown in the following example:
05 A PICTURE 9999.
05 B REDEFINES A PICTURE 9V999.
05 C REDEFINES B PICTURE 99V99.
When more than one level-01 entry is written subordinate to an FD entry, a condition known as implicit redefinition occurs. That is, the second level-01 entry implicitly redefines the storage allotted for the first entry. In such level-01 entries, the REDEFINES clause must not be specified.
When the data item implicitly redefines multiple 01-level records in a file description (FD) entry, items subordinate to the redefining or redefined item can contain an OCCURS DEPENDING ON clause.