ILE RPG considerations for DDM
ILE RPG programs and automatic report programs can both refer to DDM files. Generally, DDM file names can be specified in ILE RPG programming language anywhere a database file name can be specified, for both iSeries™ and non-iSeries target servers.
- DDM file names can be specified on the Create RPG Program (CRTRPGPGM) and Create Auto Report Program (CRTRPTPGM) commands:
- To access remote files containing source statements, on an iSeries server or a non-iSeries server, a DDM file name can be specified on the SRCFILE parameter, and a member name can be specified on the SRCMBR parameter.
- For iSeries or System/38™ target servers, a remote iSeries or System/38 source file (and, optionally, member) can be accessed in the same manner as a local source file and member.
- For non-iSeries target servers, a remote source file can be accessed if both the PGM and SRCMBR parameter defaults are used on either command. Or, if a member name is specified, it must be the same as the DDM file name specified on the SRCFILE parameter. (The same is true for member names specified either on the /COPY statement of the input specifications used to create an automatic report program or as used by the compiler to include source specifications.)
- To place the compiler listing in a database file on a target server, a DDM file name can be specified on the PRTFILE parameter of either command.
- A DDM file name and member name can be specified on the OUTFILE and OUTMBR parameters of the CRTRPTPGM command, but before the output produced by the command can be stored in the remote file referred to by the DDM file, the remote file must already exist. Also, as with local files, the record format of the remote file must match the required OUTFILE parameter format. Generally, this means that the target server must be an iSeries server or a System/38.
When an ILE RPG program opens a DDM file on the source server, the following types of I/O operations can be performed on the remote file at the target server, for both iSeries and non-iSeries targets: CHAIN, CLOSE, DELET, EXCPT, FEOD, OPEN, READ, READE, READP, SETGT, SETLL, UPDAT, and WRITE.
Other considerations are:
- If the DDM file is declared in the program to be externally described, the ILE RPG compiler copies the external descriptions of the remote file referred to into the program at compile time. However, if the remote file is not on an iSeries server or a System/38, the field declares for the record descriptions do not have meaningful names. Instead, all of the field names are declared as Fnnnnn and the key fields are declared as Knnnnn.
A recommended method for describing remote files, when the target is not an iSeries server or a System/38, is to have the data description specifications (DDS) on the local server and enter a Create Physical File (CRTPF) command or a Create Logical File (CRTLF) command on the local server. Compile the program using the local file name. Ensure that the remote system's file has the corresponding field types and field lengths.
To access the remote file, use the Override with Database File (OVRDBF) command preceding the program, for example:
OVRDBF FILE(PGMFIL) TOFILE(DDMFIL) LVLCHK(*NO)
- A DDM file is also valid as the file specified in the ILE RPG program that will be used implicitly in the ILE RPG logic cycle.
- A record format name, if used, must match the DDM file name when the target server is not an iSeries server or a System/38.
- An ADDROUT file created on a System/36™ cannot be used on an iSeries server. iSeries System/36-Compatible RPG II uses 3-byte ADDROUT files, and ILE RPG programming language on an iSeries server and System/38 uses 4-byte ADDROUT files.
Parent topic:
Programming language considerations for DDM