COBOL Manual for TNS and TNS/R Programs
Data Fundamentals
HP COBOL Manual for TNS and TNS/R Programs—522555-006
4-4
Records
Records
A record is a sequence of character positions. It can be an elementary data item or a
data structure. Its data description entry determines its internal structure (see
PICTURE Clause). Records can be of fixed length or variable length. COBOL
programs manipulate logical records and physical records.
Most of the data in a typical COBOL program is in records. When a program reads
data from or writes data to a file, the unit of transmission is the record.
Topics:
•
Physical Records and Logical Records
•
Record Elements
•
Record Length
Physical Records and Logical Records
COBOL programs manipulate physical records and logical records. A physical record
is a physical unit of information whose size and recording mode is convenient to a
particular computer for the storage of data on an input or output device (such as 80
characters for a terminal or 132 characters for a printer). The size of a physical record
is hardware dependent and bears no direct relationship to the size of the file of
information contained on a device. A physical record can contain one or several logical
records, or a logical record can span several physical records.
A logical record is a group of related information, uniquely identifiable, and handled as
a unit. The number of logical records that can exist in a file is a characteristic of its
supporting storage medium, possibly modified by instructions presented to the file
system during the file’s creation. The logical records of a file have either a fixed size or
a size that varies between a maximum and minimum size, depending on record type.
A logical record is defined by a set of data description entries. Each entry has a level-
number followed by a data-name and possibly a series of independent clauses. The
level-numbers form a structure, dividing a record into smaller and smaller parts.
Note. In this manual, “record” means logical record unless “physical record” is specified.
Example 4-2. Logical Record
01 BIBLIOGRAPHY-RECORD.
03 AUTHOR-NAME.
05 LAST-NAME PICTURE X(20).
05 FIRST-NAME PICTURE X(20).
03 TITLE PICTURE X(50).
03 PUBLICATION-INFO.
05 PUBLISHER.
07 PUB-NAME PICTURE X(20).
07 PUB-LOCATION PICTURE X(20).
05 PUBLICATION-YEAR PICTURE 9999.