The successful execution of an OPEN statement determines the availability of the file and results in that file being in an open mode. The file is unavailable if the OPEN operation fails. A file is available if it is physically present and is recognized by the input-output control system. OPEN Statement Programming Notes shows the results of opening available and unavailable files.
Related Information:
In some cases, a file that would not otherwise be available will be created by the OPEN statement. This feature is referred to as Dynamic File Creation.
+-------------------------------IBM Extension--------------------------------+
In ILE COBOL, dynamic file creation will only occur for files that are assigned to DISK. In addition, either OPTION(*CRTF) must be specified in the CRTCBLMOD or CRTBNDCBL command, or the CRTF option must be included in a PROCESS statement. If OPTION(*NOCRTF) or PROCESS NOCRTF is specified, or if the option is not defined, then no file that is defined in the program can be created dynamically.
If dynamic file creation has been specified, the following types of file will be created if they are not present when the OPEN statement is executed:
Optional files are those defined using a SELECT OPTIONAL clause. A compile-time error message will be issued for an OPEN I-O or OPEN EXTEND statement for an optional file, unless dynamic file creation is in effect for the file.
The default attributes of a dynamically created file are based on those of the file QAXXDBF held in library QSYS. The command CHGPF may be used to change these attributes, for example, to increase the maximum number of records, or to reduce the record wait time.
If a library-name has been provided by means of a file override, the file will be created in that library. If no file override is in effect, the file will be created in the current library, or if no current library is defined, in library QTEMP.
The maximum record length for a file that can be created dynamically is 32 766 characters.
+----------------------------End of IBM Extension----------------------------+
+-------------------------------IBM Extension--------------------------------+
The file may be placed under commitment control. See "Commitment Control" in the ILE COBOL for AS/400 Programmer's Guide for more information.
If the file contains null-capable fields,
and ALWNULL was not specified on the ASSIGN clause for the file, a file status of 0P is set, and only the records that do not contain null fields may be processed. Otherwise, if ALWNULL was specified for a null-capable file, null fields can be processed, and file status 0P is not set.
+----------------------------End of IBM Extension----------------------------+
(C) Copyright IBM Corporation 1992, 2006. All Rights Reserved.