PFILE (Physical File) keyword—logical files only

You can use this record-level keyword to identify the physical files that contain the data to be accessed through the record format that you are defining.

The format of the keyword is:
PFILE([library-name/]physical-file-name [.32])

The PFILE keyword is required on every record format in a simple or multiple format logical file. This keyword is similar to the JFILE keyword except that it identifies this file as a simple or multiple format logical file; the PFILE keyword is not allowed with the JFILE keyword. Up to 32 physical file names can be specified on PFILE keywords in a logical file. If the maximum is being used, 32 physical file names can be specified on one record format (using one PFILE keyword) or 32 physical file names can be distributed among 32 record formats; or, file names can be unevenly distributed among record formats. In any case, the maximum number of physical file names allowed is 32. For restrictions on specifying multiple physical files when creating a logical file, see the appropriate high-level language manual.

For each physical-file-name, a library-name is optional. If the library-name is omitted, the library list (*LIBL) that is in effect at file creation time is used.

If you specify more than one physical file name for one record format in a multiple format logical file, all fields in the record format for the logical file must exist in all physical files specified. This type of file cannot be externally described in RPG because it results in duplicate format names. If your program requires access to fields that occur in one or more of the physical files specified on the PFILE keyword, but not in all of them, you can do one of the following tasks:
  • Specify a join logical file. If you do this, use the JFILE keyword instead of the PFILE keyword.
  • Specify a separate logical file record format that includes fields not in the first physical file.

    For instance, if FLD1 and FLD2 occur in physical files PF1, PF2, and PF3, but FLD3 occurs only in PF3, you cannot specify FLD3 in a logical file record format based on PF1 and PF2. To provide access to FLD3, either specify a second logical file record format that includes FLD3 or use a join logical file.

    You cannot use a simple or multiple format logical file to bring together into one record format fields from separate physical files. Use a join logical file to accomplish this. A record read through the use of a record format in a simple or multiple format logical file can contain data from only one physical file, and a record written through the use of a record format in a logical file can be stored only in one physical file.

Distributed data management (DDM) files are allowed on the PFILE keyword only when the logical file is being created on a remote system.

Examples

The following examples show how to specify the PFILE keyword.

Example 1

|...+....1....+....2....+....3....+....4....+....5....+....6....+....7....+....8
00010A          R LOGRCD1                   PFILE(PF1)
     A

In this example, LOGRCD1 can use fields only in PF1.

Example 2

|...+....1....+....2....+....3....+....4....+....5....+....6....+....7....+....8
00010A          R LOGRCD2                   PFILE(PF1 PF2)
     A               :
     A               :
00020A          R LOGRCD3                   PFILE(PF1 PF2 PF3)
     A               :
     A               :
     A

In this example, LOGRCD2 must use fields common to PF1, and PF2, and LOGRCD3 must use fields common to PF1, PF2, and PF3.

Example 3

|...+....1....+....2....+....3....+....4....+....5....+....6....+....7....+....8
00010A          R LOGRCD4                   PFILE(PF1)
     A               :
     A               :
00020A          R LOGRCD5                   PFILE(PF2)
     A               :
     A               :
00030A          R LOGRCD6                   PFILE(LIB1/PF6)
     A

In this example, LOGRCD4, LOGRCD5, and LOGRCD6 can have unique fields. LOGRCD6 specifies a qualified physical-file name.