Dynamic File Creation

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
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:
  • Sequential and Relative files opened for OUTPUT.
  • Optional Sequential and Relative files opened for I-O.
  • Optional Sequential files opened EXTEND.

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
End of IBM Extension