COBOL Manual for TNS and TNS/R Programs
Data Fundamentals
HP COBOL Manual for TNS and TNS/R Programs—522555-006
4-5
Records
The concept of logical records also applies to data outside files. You can group data
into logical records in all sections of the Data Division.
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 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.