CLOSE statement
The CLOSE statement terminates the processing of volumes and files.
- file-name-1
- Designates the file upon which the CLOSE statement is to operate. If more than one file-name is specified, the files need not have the same organization or access. file-name-1 must not be a sort or merge file.
- REEL and UNIT
- REEL and UNIT are syntax checked, but have no effect on the execution of the program.
- WITH NO REWIND and FOR REMOVAL
- WITH NO REWIND and FOR REMOVAL are syntax checked, but have no effect on the execution of the program.
A CLOSE statement can be executed only for a file in an open mode. After successful execution of a CLOSE statement (without the REEL/UNIT phrase if using format 1):
- The record area associated with the file-name is no longer available. Unsuccessful execution of a CLOSE statement leaves availability of the record data undefined.
- An OPEN statement for the file must be executed before any other input/output statement can be executed for the file and before data is moved to a record description entry associated with the file.
- Any record locks and file locks held by the file connector on the closed file are released.
If the FILE STATUS clause is specified in the file-control entry, the associated file status key is updated when the CLOSE statement is executed.
If the file is in an open status and the execution of a CLOSE statement is unsuccessful, the EXCEPTION/ERROR procedure (if specified) for this file is executed.