OPEN (Open File for Processing)
Free-Form Syntax | OPEN{(E)} file-name |
Code | Factor 1 | Factor 2 | Result Field | Indicators | ||
---|---|---|---|---|---|---|
OPEN (E) | file-name | _ | ER | _ |
The explicit OPEN operation opens the file named in the file-name operand. The file named cannot be designated as a primary, secondary, or table file.
To handle OPEN exceptions (file status codes greater than 1000), either the operation code extender 'E' or an error indicator ER can be specified, but not both. For more information on error handling, see File Exception/Errors.
To open the file specified in the file-name operand for the first time in a module or subprocedure with an explicit OPEN operation, specify the USROPN keyword on the file description specifications. (See File Description Specifications for restrictions when using the USROPN keyword.)
If a file is opened and later closed by the CLOSE operation in the module or subprocedure, the programmer can reopen the file with the OPEN operation and the USROPN keyword on the file description specification is not required. When the USROPN keyword is not specified on the file description specification, the file is opened at module initialization for global files, or subprocedure initialization for local files. If an OPEN operation is specified for a file that is already open, an error occurs.
Multiple OPEN operations in a program to the same file are valid as long as the file is closed when the OPEN operation is issued to it.
When you open a file with the DEVID keyword specified (on the file description specifications), the fieldname specified as a parameter on the DEVID keyword is set to blanks. See the description of the DEVID keyword, in File Description Specifications.
For more information, see File Operations.