COBOL Manual for TNS/E Programs (H06.08+, J06.03+)
Once you describe the relationship between logical records and physical records, record
manipulation is the responsibility of the HP COBOL or CRE run-time routines and the NonStop
operating system.
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 13, 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 13, 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 (page 154)). 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.
When a file has the variable-length record type attribute, different records can have different
numbers of character positions. In this case the input and output operations on the file process
whatever size is associated with a particular logical record. After a record retrieval operation, the
source program has sole responsibility for determining which of the possible record formats or
lengths apply. The logical record length associated with a variable-length record file is therefore
a maximum that records cannot exceed, not a constant to which all records conform.
80 Data Fundamentals










