Types of File Descriptions
- For a program-described file, you can
use a data structure to hold the data for your file operations, or for global
files, you can code the descriptions of the fields within the RPG source member
on input and/or output specifications.
The description of the file to the operating system includes information about where the data comes from and the length of the records in the file.
- For an externally described file, the compiler retrieves
the description of the fields from an external file-description which was
created using DDS, IDDU, or SQL commands. Therefore, you do not have to code
the field descriptions on input and/or output specifications within the RPG
source member.
The external description includes information about where the data comes from, such as the database or a specific device, and a description of each field and its attributes. The file must exist and be accessible from the library list before you compile your program.
- Less coding in programs. If the same file is used by many programs, the fields can be defined once to the operating system and used by all the programs. This practice eliminates the need to code input and output specifications for RPG programs that use externally described files.
- Less maintenance activity when the file’s record format is changed. You can often update programs by changing the file’s record format and then recompiling the programs that use the files without changing any coding in the program.
- Improved documentation because programs using the same files use consistent record-format and field names.
- Improved reliability. If level checking is specified, the RPG program will notify the user if there are changes in the external description. See Level Checking for further information.
If an externally described file (identified by an E in position 22 of the file description specification) is specified for the devices SEQ or SPECIAL, the RPG program uses the field descriptions for the file, but the interface to the operating system is as though the file were a program-described file. Externally described files cannot specify device-dependent functions such as forms control for PRINTER files because this information is already defined in the external description.