COBOL Manual for TNS and TNS/R Programs
Data Fundamentals
HP COBOL Manual for TNS and TNS/R Programs—522555-006
4-14
Data Representation
A COBOL table can have a maximum of 7 dimensions. If the description of a data item
T-B-S subordinate to TOTAL-B also has an OCCURS clause, T-B-S is a 3-dimensional
table.
The outermost table of a multidimensional table can be of variable size, but each
subordinate table must be of fixed size.
Data Representation
To define a language independent of computer designs, COBOL describes the
structure and representation of data in terms of a standard data format. This format
represents numbers as integers and represents noninteger and nonnumeric data as
strings of characters. The amount of computer storage space occupied by data is
measured in character positions. A data item’s description determines how many
character positions it has. How data is stored depends on the machine on which it
executes.
A character position in an HP computer system is a byte: an 8-bit quantity. Data items
represented as strings of characters occupy one byte per character. HP COBOL has
other data formats that do not maintain the values of data items in characters but use
forms more suitable for certain operations. In such cases, the number of bytes into
which a data item fits can differ from the number of characters that express the value
of the item.
When an arithmetic or MOVE statement stores a value in a COMPUTATIONAL item,
the number of digits stored equals the number of 9 s in the item’s PICTURE clause.
Because MOVE statements lack the SIZE ERROR phrase, they cannot detect the loss
of high-order digits.
In general, the set of bytes the compiler allocates for a record is simply the contiguous
sequence of bytes necessary to accommodate its constituent elementary data items. In
some cases, however, alignment considerations cause the compiler to allocate unused
bytes between data items. These bytes are called implicit FILLER bytes (see Implicit
FILLER Bytes).
Example 4-5. Multidimensional Table
02 TOTAL OCCURS 20 TIMES.
03 TOTAL-A ...
03 TOTAL-B OCCURS 3 TIMES ...
Table 4-6. Allocation for COMPUTATIONAL Data Items
PICTURE Size in Digits Byte Allocation
1 through 4 2 bytes
5 through 9 4 bytes
10 through 18 8 bytes