COBOL Manual for TNS/E Programs (H06.08+, J06.03+)

Tables
When an elementary data item is described with an OCCURS clause, is subordinate to a data
structure described with an OCCURS clause, or both, all occurrences of the data item must be
aligned uniformly:
1. The first occurrence of the item is aligned to the required storage boundary. If the elementary
item also begins a containing table’s first occurrence, that table’s first occurrence is defined
to begin at the first character position of the item.
2. When the aligned item is itself a table, the first occurrence ends on the appropriate storage
boundary and the remaining occurrences follow without additional FILLER bytes.
3. When the aligned item (or table of aligned items) belongs to a higher-level table, further
adjustment can be necessary.
If the elementary item is 2-byte-aligned and the containing group occurrence consists of an
odd number of character positions, the compiler inserts one byte of FILLER after each group
occurrence.
The preceding steps are repeated for each higher-level table.
FILLER bytes are not part of the containing occurrences themselves, but are included in data structures
that contain the complete table.
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 17, 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.
Example 17 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.
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.
References to Data Items 89