COBOL Manual for TNS and TNS/R Programs

Data Fundamentals
HP COBOL Manual for TNS and TNS/R Programs522555-006
4-18
REDEFINES Clause
REDEFINES Clause
When a data structure that is the object of a REDEFINES clause contains implicit
FILLER bytes, their character positions are included in the character positions
redefined.
Automatic or requested alignment of data items described by redefinition of a record’s
character positions (through use of the REDEFINES clause) follows the rules
described previously. When the first data item allocated by a redefinition requires 2-
byte or 4-byte alignment, the data item being redefined must begin on the appropriate
boundary within its record. HP COBOL does not permit redefinitions that require
insertion of implicit FILLER bytes before the first data item of the redefinition. Any bytes
inserted at other places within the redefinition are counted when determining its size.
In Example 4-6, MASTER appears to occupy this many bytes:
(((2+1) * 5+1 ) * 5+1) * 5 = 405 bytes
but it actually occupies this many bytes
(((2+1+1) * 5+1+1) * 5+1+1) * 5 = 560 bytes
due to the alignment requirement for the COMPUTATIONAL item.
References to Data Items
To refer to a data item, a statement in a COBOL program must contain a reference that
uniquely identifies that data item. In some cases, data items do not have unique
names; for example:
All elements of a table share a single name.
Items that have the same name can occur in different records.
To make references unique, you can use qualifiers, subscripts, and reference
modifiers. A data-name made unique by a combination of qualifiers, subscripts, and
reference modifiers is called an identifier.
If an item in a record is tested frequently by a program, assigning a condition-name to
the item is a convenient way to refer to the item and show the significance of the item’s
value. Assigning a condition-name to the item is also good programming practice.
Example 4-6. REDEFINES Clause
01 MASTER.
02 TABLE-1 OCCURS 5 TIMES.
03 TABLE-2 OCCURS 5 TIMES.
04 TABLE-3 OCCURS 5 TIMES.
05 ITEM-A PIC 99 USAGE IS COMP.
05 ITEM-B PIC X.
04 ITEM-3 PIC X.
03 ITEM-2 PIC X.