COBOL Manual for TNS/E Programs (H06.08+, J06.03+)

entry-sequenced; if it is declared ORGANIZATION RELATIVE, the file must be relative;
and if it is declared ORGANIZATION INDEXED, the file must be key-sequenced).
If the file is key sequenced or has alternate keys, the declaration of the keys in the COBOL
program must agree with the declaration of the keys in the file system.
The file security must be appropriate for the open mode. You cannot open a file for INPUT
or I-O if it is secured against your reading it. You cannot open a file for OUTPUT, I-O, or
EXTEND if it is secured against your writing to it.
CAUTION: If you open a disk file for shared access, do not use sequential block
buffering, because one process can read data from the file that is not up-to-date while
another process is altering the file. See the explanation of the RESERVE clause in file-control
entries under FILE-CONTROL Paragraph (page 115).
When the preceding requirements are met for a disk file present at run time, the open
mode determines what happens during execution.
Table 67 Open Modes for Structured Disk Files Present at Run Time
ActionOpen Mode
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.
INPUT
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
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:
OUTPUT
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
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.
EXTEND
The file position indicator is set to the end of the file.
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.
I-O
386 Procedure Division Verbs