Closing line-sequential files
Use the CLOSE
statement to disconnect your program
from a
line-sequential file. If you try to close a file that is already
closed, you will get a logic error.
About this task
If you do not close a line-sequential file, the file is automatically closed for you under the following conditions:
- When the run unit ends normally.
- When the run unit ends abnormally, if the
TRAP(ON)
runtime option is set. - When Language Environment® condition
handling is completed and the application
resumes in a routine other than where the condition occurred, open
files defined in any COBOL programs in the run unit that might be
called again and reentered are closed.
You can change the location where the program resumes (after a condition is handled) by moving the resume cursor with the Language Environment CEEMRCR callable service or using HLL language constructs such as a C longjmp call.
File status codes are set when these implicit CLOSE
operations
are performed, but EXCEPTION/ERROR
declaratives are
not invoked.
Related tasks
Opening line-sequential files
Reading records from line-sequential files
Adding records to line-sequential files
Allocating line-sequential files
Opening line-sequential files
Reading records from line-sequential files
Adding records to line-sequential files
Allocating line-sequential files