File Description Specifications

File description specifications identify each file used by a module or procedure. Each file in a program must have a corresponding file description specification statement.

A file can be either program-described or externally described. In program-described files, record and field descriptions are included within the RPG program (using input and output specifications). Externally described files have their record and field descriptions defined externally using DDS, SQL commands, or a screen designer or print designer such as those available in Rational® Developer for i.

You define an externally-described file in free-form by specifying *EXT for the file-device keyword or by specifying the keyword without a parameter. You define a program-described file in fixed-form by specifying E in position 22 of the file description specification.

You define a program-described file in free-form by specifying a record length for the file-device keyword. You define a program-described file in fixed-form by specifying F in position 22 of the file description specification.

You can specify file specifications in two different formats:
The following limitations apply:
  • Only one primary file can be specified. It must be specified as a global file. The presence of a primary file is not required.
  • Only one record-address file is a allowed in a module; it must be defined as a global file.
  • A maximum of eight PRINTER files is allowed for global files defined in the main source section, and a maximum of eight local PRINTER files is allowed in each procedure.
  • There is no limit for the maximum number of files allowed.
  • Local files defined in subprocedures must be full-procedural files.
  • Files defined in subprocedures do not have Input and Output specifications, so all input and output must be done using data structures.