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

Procedure Division Verbs
HP COBOL Manual for TNS/E Programs520347-003
9-139
OPEN
°
If the file code is 101 (EDIT format) because either the file already exists
with that code or an ASSIGN command with a CODE phrase has been
processed for the file, the file can be opened in INPUT, OUTPUT, or
EXTEND modes. Opening the file for OUTPUT deletes any existing
records in the file and starts the line numbers at 1, and increments by 1.
Opening the file for EXTEND retains existing records and starts the line
numbers at 1 greater than the number of the last line in the file, and
increments by 1. An EDIT-format file cannot be opened for OUTPUT or
EXTEND if the NONSTOP directive has been specified.
°
If the file code is 180 (line sequential, available only in the OSS
environment).
°
The file must be described as having fixed-length records (absence of the
rec-1 TO phrase and the VARYING phrase in the RECORD clause).
°
If the file is opened in EXTEND mode, the file position indicator is
advanced to the end of the file.
Structured Disk Files Not Present at Run Time
The open mode determines what happens when a structured disk file is not
present at run time.
Table 9-8. Open Modes for Structured Disk Files Not Present at Run Time
Open Mode Action
INPUT When the SELECT clause for the file contains the word OPTIONAL, the
OPEN statement completes successfully, and COBOL simulates the
existence of an empty disk file. If the file is not described as OPTIONAL, the
open operation fails.
OUTPUT or
EXTEND or
I-O
If a file is described with alternate-record keys, the open operation fails. A
COBOL program cannot create files with alternate keys. When the disk file
is otherwise described, COBOL creates the file (see Structured Disk Files
Present at Run Time).
If the device name is associated with a proper file name (such as
$volumename.subvolname.filename), then the created file is permanent and
continues to exist after the program has closed it. If the device name is not
associated with a proper file name (that is, if its name has the form of just a
volume name or is a special name like #TEMP), the created file is temporary
and disappears when it is closed.
The device name can be associated with a proper file name in any of these
ways:
By the ASSIGN clause at compile time
By an ASSIGN command at run time
By a DEFINE of class MAP at run time