COBOL Manual for TNS and TNS/R Programs
Procedure Division Verbs
HP COBOL Manual for TNS and TNS/R Programs—522555-006
9-153
OPEN
Table 9-9. Open Modes for Structured Disk Files Present at Run Time
Open Mode Action
INPUT If the record length of the physical file is shorter than the record length
declared in the File Section, and the record length is not declared as
variable (rec-1 TO rec-2 CHARACTERS or VARYING SIZE), the OPEN
statement fails.
If the open operation succeeds and the file organization is relative, the
relative key is established as the key of reference.
If the open operation succeeds and the file organization is indexed, the
prime record key is established as the key of reference.
The file position indicator is set so that the first execution of a READ
statement retrieves either of these, depending on the file’s organization:
•
The first record in a sequential file
•
The first record in the sequence defined by the key of reference in an
indexed, queue, or relative file
OUTPUT If the record length of the physical file is shorter than the record length
declared in the File Section, the file is not suitable for use:
•
If no alternate record keys exist, the file is purged and a new one is
created. The new file has file code 0 unless the COBOL_ASSIGN_
routine or the TACL command ASSIGN provides another file code
value. The new file has the standard HP COBOL defaults for file size
and number of extents, rather than the size and extents of the original
file.
•
If alternate record keys exist, the file cannot be purged, and the open
operation fails with I-O status code “30.”
If the record length of the physical file is not shorter than the record length
declared in the File Section, and the file contains some data, the file is not
purged, but its data is purged. In either case, no warning alerts you that a
purge is taking place. After the file is purged, the file position indicator is set
to either of these, depending on the file’s organization:
•
The first record in a sequential file
•
An undefined value for an indexed, queue, or relative file, because the
file contains no records at that point
EXTEND If the record length of the physical file is shorter than the record length
declared in the File Section, the file is not suitable for use. The open
operation fails with I-O status code “30.”
The file position indicator is set to the end of the file.
I-O If the record length of the physical file is shorter than the record length
declared in the File Section, the file is not suitable for use. The open
operation fails with I-O status code “30.”
The file position indicator is set to the first record in the file.