The CLOSE statement terminates the processing of reels or units, and files with optional rewind, lock, or both, or removal where applicable.
The files referenced in the CLOSE statement need not all have the same organization or access.
The NO REWIND, REEL, and UNIT phrases may only be specified for files that are sequential organization.
The function of a CLOSE statement (with no options) is to cause the runtime system to close the file. For files opened for OUTPUT, the runtime system also writes an EOF as it closes the file.
If a STOP RUN statement is executed prior to closing the file, the runtime system closes the file.Such a close is equivalent to the execution of a CLOSE statement except that any associated USE procedure is not executed.
A CLOSE statement may be executed only for a file in an open mode.
Once a CLOSE statement without the REEL or UNIT phrase has been executed for a file, no other statement (except the SORT or MERGE statement with the USING or GIVING phrase) can be executed that references that file, either explicitly or implicitly, unless an intervening OPEN statement for that file is executed.
The execution of a CLOSE statement causes the value of the file status data item, if any, associated with file-name-1 to be updated.
REEL and UNIT Phrase
The REEL and UNIT phrases are synonymous in this context.The CLOSE REEL and CLOSE UNIT statements cause processing to be discontinued on the current volume and to be continued on the next volume of a multivolume series.CLOSE REEL and CLOSE UNIT on a single-volume file are ignored.
The REEL and UNIT phrases may only be specified for sequential organization files. The action of the phrase for multivolume disk files and tape files depends on the open mode:
NO REWIND Phrase
The NO REWIND phrase may be used to write and read multiple files on a tape with a single file-name.The phrase suppresses the automatic rewinding of a tape volume when a CLOSE statement, without the NO REWIND phrase, is executed.
The NO REWIND phrase may only be specified for sequential organization files.
Following a CLOSE file-name-1 WITH NO REWIND, an OPEN file-name-1 WITH NO REWIND may be used to write or read the next file on the tape.For input, the file must be closed without rewinding after reading all the records in the file; otherwise, the open without rewinding will fail since the tape is not positioned at the beginning of a file.
The NO REWIND phrase is ignored for files that are not on tape or directed to a printer.
Specifying both the UNIT or REEL phrase and the NO REWIND phrase for a single file-name within a CLOSE statement is an allowed syntactical form, but in such a case the NO REWIND phrase has no meaning and is ignored at execution time.
The REMOVAL phrase may be used so that the operating system is notified that the reel or unit is logically removed from this run unit.However, the reel or unit may be accessed again, in its proper order of reels and units within the file, if a CLOSE statement without the REEL or UNIT phrase is subsequently executed for this file followed by the execution of an OPEN statement for the file.
The REMOVAL phrase may only be specified for sequential organization files.
The NO REWIND and REMOVAL phrases have no effect at object time if they do not apply to the storage medium on which the file resides.
The function of the CLOSE WITH LOCK statement is to perform the CLOSE function and set a flag to prevent the file from being opened again during execution of this program.In some runtime environments, the CLOSE WITH LOCK statement frees system resources that would otherwise not be freed until the run unit terminates.
The execution of a CLOSE statement always releases any file lock or record locks held by the run unit for file-name-1. The LOCK phrase of the CLOSE statement is unrelated to file locking and record locking.
CLOSE Statement Examples
COBOL Related Interview Questions
|VSAM Interview Questions||IBM - VSAM Interview Questions|
|IBM-CICS Interview Questions||JCL Interview Questions|
|IBM DB2 Interview Questions||IBM-JCL Interview Questions|
|DB2 Using SQL Interview Questions||IBM-JCL&VSAM Interview Questions|
|IBM Mainframe Interview Questions||COBOL, CICS, JCL, VSAM, DB2 Interview Questions|
|DB2 SQL Programming Interview Questions||IMS/DB Interview Questions|
|Mainframe DB2 Interview Questions|
Procedure Division Statements
All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd
Wisdomjobs.com is one of the best job search sites in India.