Direct file support with ILE COBOL

 

An iSeries™ server does not support direct files as one of its file types. However, an ILE COBOL program on iSeries server can specify that a file be accessed as a direct file.

An iSeries server normally creates direct files as sequential files. An ILE COBOL program on an iSeries server defines a file as a direct file by specifying RELATIVE on the SELECT statement. If the program is to open the file for output only (by specifying OUTPUT on the OPEN statement), the file must be created with deleted records and contain no active records. This is also the file's condition when a non-iSeries source server (such as System/36™) uses DDM to create or clear the direct file on an iSeries server, assuming that the file is created as described in the following paragraphs.

An iSeries server and System/38™ support sequential and keyed file types. DDM recognizes sequential, keyed, and direct file types. For a non-iSeries server to create a direct file on an iSeries server using DDM, the DDM architecture command Create Direct File (CRTDIRF) is used.

When the CRTDIRF architecture command is issued from a non-iSeries server to create the file, the file is created as a physical file and is designated as a direct file so that, for subsequent direct file access by non-iSeries source servers, it will be identifiable to the other server as a direct file. If the file is not created in this way, an iSeries server cannot later determine whether the file is a direct file or a sequential file, again, because an iSeries server does not have direct files as one of its file types.

Therefore, if an ILE COBOL program on a server other than an iSeries server or a System/38 needs to access an iSeries or a System/38 file in a direct mode (that is, by relative record number) for output, the file must have been created by the CRTDIRF architecture command.

To support direct files on an iSeries server for output only, the ILE COBOL OPEN statement clears and prepares a member of a file being opened. Therefore, existing iSeries or System/38 files can be accessed by using DDM files by ILE COBOL programs on other iSeries servers or System/38s. For non-iSeries target servers, relative files opened for output must be defined as direct files or an error occurs.

In summary:

 

Parent topic:

ILE COBOL considerations for DDM