COBOL Manual for TNS and TNS/R Programs
Procedure Division Verbs
HP COBOL Manual for TNS and TNS/R Programs—522555-006
9-148
OPEN
•
Nonexistent Files
When the INPUT, I-O, or EXTEND phrase applies and the SELECT clause
includes the OPTIONAL phrase, the run-time routines determine whether or not
the file is present.
If the file is not present, one of these occurs:
°
If the I-O or EXTEND phrase applies, the open operation creates a file. This
creation occurs as if these statements were executed in the order shown:
OPEN OUTPUT file-name.
CLOSE file-name.
The OPEN statement as specified in the source program is then executed. If
the file is defined to have alternate keys, the creation attempt fails because you
cannot create such files with COBOL verbs. They must be created by an
application outside the HP COBOL language (for example, by FUP, the File
Utility Program, or by using ENTER to call Enscribe routines).
If the creation attempt succeeds, then the file exists. Files Assigned to Disk
Devices explains the rules for existing disk files.
After a successful open operation that creates a file in the manner described,
the I-O status code is “05,” rather than “00” (as it would have been if the
operation had opened an existing file).
Table 9-5. I-O Statements You Can Use in Different Open Modes
I-O Statement
Open Mode
INPUT OUTPUT I-O EXTEND
READ ALL ALL
WRITE ALL Org: R, I
Acc: R, D
Org: S, R, I
Acc: S
REWRITE ALL
START Org: S*, R, I
Acc: S, D
Org: S*, R, I
Acc: S, D
DELETE Org: R, I
Org is the file’s organization: I = Indexed or queue
R = Relative
S = Sequential
S* = Sequential (but only for START specifying an alternate key)
Acc is the file’s access mode: S = Sequential
R = Random
D = Dynamic
ALL means all organizations and access modes