*---------*---------------*-----------------*----------------*---------------* | CODE | FACTOR 1 | FACTOR 2 | RESULT | INDICATORS | | | | | FIELD | | *---------*---------------*-----------------*----------------*---------------* | OPEN | | File name | | _ ER _ | *---------*---------------*-----------------*----------------*---------------*
The explicit OPEN operation opens the file named in factor 2. The factor 2 entry cannot be designated as a primary, secondary, or table file. You can specify a resulting indicator in positions 56 and 57 to be set on if the OPEN operation is not successful. If no indicator is specified, but the INFSR subroutine is specified, the INFSR automatically receives control when an error/exception occurs. If no indicator or INFSR subroutine is specified, the default error/exception handler receives control when an error/exception occurs.
To open the file specified in factor 2 for the first time in a program with an explicit OPEN operation, specify UC (user control) in positions 71 and 72 of the file description specifications. (See File Description Specifications for restrictions when using the UC entry.)
If a file is opened and later closed by the CLOSE operation in the program, the programmer can reopen the file with the OPEN operation and the UC entry is not required in positions 71 and 72. When UC is not specified, the file is opened at program initialization. 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 ID option specified (on the file description specifications continuation line), the ID field is set to blanks. See the description of the ID option, in File Description Specifications.
Figure "OPEN Operation with CLOSE Operation" shows the OPEN operation used with the CLOSE operation.
Figure 42. OPEN Operation with CLOSE Operation
*...1....+....2....+....3....+....4....+....5....+....6....+....7... FFilenameIPEAF....RlenLK1AIOvKlocEDevice+......KExit++Entry+A....U.. FEXCPTN O E DISK UC FFILEX I E DISK *...1....+....2....+....3....+....4....+....5....+....6....+....7... CL0N01N02N03Factor1+++OpcdeFactor2+++ResultLenDHHiLoEqComments++++++ C* C* The explicit OPEN operation opens the EXCPTN file for C* processing if indicator 97 is on and indicator 98 is off. C* Note that the EXCPTN file on the file description C* specifications has UC specified in positions 71 and 72. C* C 97N98 OPEN EXCPTN 99 99=NO SUCCESS C 97N98N99 WRITEERREC C* C* FILEX is opened at program initialization. The explicit C* CLOSE operation closes FILEX before control is passed to RTNX. C* RTNX or another program can open and use FILEX. Upon return, C* the OPEN operation reopens the file. Because FILEX is opened C* at program initialization, UC is not specified in positions 71 C* and 72 of the file description specifications. C* C CLOSEFILEX C CALL 'RTNX' C OPEN FILEX
(C) Copyright IBM Corporation 1992, 2006. All Rights Reserved.