COBOL Manual for TNS and TNS/R Programs
Data Fundamentals
HP COBOL Manual for TNS and TNS/R Programs—522555-006
4-6
Files
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.
The OCCURS clause with a DEPENDING ON phrase defines a variable-size table. For
more information, see OCCURS Clause for Variable-Size Tables.
Files
A file is the highest structural form. Each file is a collection of records, ordered by the
file’s organization or by record attributes (keys), and maintained upon some storage
medium. Use of the record structure is not limited to files; individual records can exist
independently of files.
In COBOL, a file is a group of records. A file has both fixed attributes and dynamic
attributes. Fixed attributes are determined when you create the file, and you cannot
change them subsequently. Dynamic attributes can vary to some extent, depending on
the logical specifications that source programs request when they access the file.
Some attributes are language-specific. Regardless of file system or operating system,
COBOL files have a certain logical structure (organization and access mode). The
operating system provides an additional attribute of a file: an exclusion mode when the
file is open.
A COBOL program references a file by its file connector, which contains information
about the file’s attributes. One component of the file connector is the file position
indicator, which determines which record is the next one to be sequentially accessed.
Topics:
•
Organization
•
Access Mode
•
Open Mode
•
Exclusion Mode
•
File Connector
•
File Position Indicator