Implicit opening
An implicit opening of a file occurs when a GET, PUT, READ, WRITE, LOCATE, REWRITE, or DELETE statement is executed for a file for which an OPEN statement has not already been executed.
If a GET statement contains a COPY option, execution of the GET statement can cause implicit opening of either the file specified in the COPY option, or, if no file was specified, the output file SYSPRINT. Implicit opening of the file specified in the COPY option implies the STREAM and OUTPUT attributes.
Table 1 shows the attributes that are implied when a given statement causes the file to be implicitly opened.
| Statement | Implied attributes |
|---|---|
| GET | STREAM, INPUT |
| PUT | STREAM, OUTPUT |
| READ | RECORD, INPUTNote |
| WRITE | RECORD, OUTPUTNote |
| LOCATE | RECORD, OUTPUT, SEQUENTIAL |
| REWRITE | RECORD, UPDATE |
| DELETE | RECORD, UPDATE |
| Note: INPUT and OUTPUT are default attributes for READ and
WRITE statements only if UPDATE has not been explicitly declared.
|
|
When one of the statements listed in Table 1 opens a file implicitly, it is functionally equivalent to using an explicit OPEN statement for the file with the same attributes specified.
There must be no conflict between the attributes specified in a file declaration and the attributes implied as the result of opening the file. For example, the attributes INPUT and UPDATE are in conflict, as are the attributes UPDATE and STREAM.
The implied attributes are applied before the default attributes that are listed in Table 1 in File constant are applied. Implied attributes can also cause a conflict. If a conflict in attributes exists after the application of default attributes, the UNDEFINEDFILE condition is raised.
| Merged attributes | Implied attributes |
|---|---|
| UPDATE | RECORD |
| SEQUENTIAL | RECORD |
| DIRECT | RECORD, KEYED |
| OUTPUT, STREAM | |
| KEYED | RECORD |