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

Data Fundamentals
HP COBOL Manual for TNS/E Programs520347-003
4-5
Records
Record Elements
In COBOL, the lowest subdivisions of a record (that is, those not further subdivided)
are called elementary items. Consequently, a record is a series of elementary items, or
the record itself can be an elementary item. In Example 4-2, the elementary items are:
LAST-NAME
FIRST-NAME
TITLE
PUB-NAME
PUB-LOCATION
PUBLICATION-YEAR
A data structure is a sequence of one or more elementary items that you can refer to
by a group name. Data structures in turn can be combined to make other data
structures. An elementary item, then, can belong to more than one data structure. A
record is a data structure that does not belong to any larger data structure. In
Example 4-2, the data structures that contain more than one elementary item are:
AUTHOR-NAME
PUBLICATION-INFO
PUBLISHER
BIBLIOGRAPHY-RECORD
Record Length
The length of records can be fixed or variable. You specify the length in the file
description entry that precedes any data description entries for the records (see File
Section). If the file description entry includes a
RECORD CONTAINS rec-1 TO rec-2 CHARACTERS
or a
RECORD IS VARYING IN SIZE FROM rec-1 TO rec-2 CHARACTERS
clause, the record length is variable. If the file description entry has no RECORD
CONTAINS clause, or if the clause is
RECORD CONTAINS n CHARACTERS
the record length is fixed.
When a file has the fixed-length record type attribute, every record contains the same
number of character positions (bytes) and all input and output operations on the file
process this fixed size. A program can specify more than one record description for the
file, and some record descriptions can describe different numbers of character
positions, but every record existing in the file still has the same fixed length.