COBOL Manual for TNS and TNS/R Programs

Procedure Division Verbs
HP COBOL Manual for TNS and TNS/R Programs522555-006
9-38
CLOSE for Sequential and Line Sequential Files
UNIT
REEL
specify that the current reel is to be closed and rewound, and a new reel is to
be mounted.
REMOVAL
specifies that the reel of a multiple-reel tape file be rewound and unloaded, and
a new reel is to be mounted.
NO REWIND
specifies that the sequential file is to be left in its current position, not rewound.
LOCK
means the file associated with file-name cannot be opened again during
the current run. If the file is dynamically assignable, the LOCK phrase has no
effect (see #DYNAMIC).
Usage Considerations:
Effects of CLOSE
For each file-name in the CLOSE statement, the run-time routines perform an
appropriate close operation. These close operations occur as if separate CLOSE
statements were executed for each file-name in the order listed. Subsequent
usage considerations describe actions taken during the close operation for one file.
File-Status Data Item
If the file being closed has an associated file-status data item, the CLOSE
statement assigns it an appropriate I-O status code. The possible I-O status codes
and their meanings are:
Failure of a close operation can terminate the run unit. When a run unit terminates
for any reason (normal or abnormal), the run-time routines implicitly close any
open files as if they were specified in a CLOSE statement without optional
phrases.
I-O Status Code Meaning
“00” The close operation completed successfully.
“07” The close operation completed successfully, but the CLOSE
statement included a NO REWIND, REEL, UNIT, or REMOVAL
phrase and the designated file does not reside on a reel or unit
medium.
“30” The close operation failed due to causes outside of COBOL. The
file is not closed. If the operation was a reel close, the reel might
not have been closed properly.
“42 The program attempted to close a file that was not open.