COBOL Manual for TNS and TNS/R Programs

Data Division
HP COBOL Manual for TNS and TNS/R Programs522555-006
7-49
REDEFINES Clause
Usage Considerations:
Determining Size of Shared Storage Area
When the redefined item is a record item and one or more redefinitions specify a
different number of character positions than the redefined item (either greater or
lesser), the size of the shared storage area is determined by the requirements of
the largest associated record item.
Elementary items or Data Structures Can Be Redefined
You can describe an elementary data item and follow that description with a
redefinition entry. You can also describe a data structure and follow that description
first with descriptions of its component elementary items (with numerically higher
level numbers), then with a redefinition entry that redefines the data structure.
Redefinition continues until the appearance of a level number less than or equal to
that of the data-name being redefined (or the ending of the current section of the
Data Division).
Series of Redefinitions
You can describe a series of redefinition entries with the same level number as that
of the redefined entry, provided that each of these entries also contains a
REDEFINES clause specifying the data-name of the redefined item.
You cannot, however, separate a redefinition entry from the redefined entry by any
data description entry with a numerically lower level number.
No Redefinitions of Level-66 or Level-88 Items
Data items of level 66 (RENAMES) and 88 (condition-name) cannot be redefined.
Example 7-11. REDEFINES Clause
WORKING-STORAGE SECTION.
01 RECORD-IN.
05 RECORD-CODE PIC 9.
05 RECORD-DETAIL PIC X(30).
05 RECORD-SUBTOTAL PIC 9(3)V99.
01 RECORD-TOTAL REDEFINES RECORD-IN.
05 TOTAL-1 PIC 9(5)V99.
05 TOTAL-2 PIC 9(5)V99.
05 TOTAL-3 PIC 9(5)V99.
05 TOTAL-4 PIC 9(5)V99.
05 TOTAL-5 PIC 9(6)V99.