Joining a Physical File to Itself (Example 8)

You can join a physical file to itself to read records that are formed by combining two or more records from the physical file itself. The following example shows how:
Examples of Records

The following shows the DDS for these files:



JLF
|...+....1....+....2....+....3....+....4....+....5....+....6....+....7....+....8
     A                                      JDFTVAL
     A          R JOINREC                   JFILE(PF1 PF1)
     A          J                           JOIN(1 2)
     A                                      JFLD(MGRNBR NBR)
     A            NBR                       JREF(1)
     A            NAME                      JREF(1)
     A            MGRNAME                   RENAME(NAME)
     A                                      JREF(2)
     A
 
PF1
|...+....1....+....2....+....3....+....4....+....5....+....6....+....7....+....8
     A          R RCD1
     A            NBR            3
     A            NAME          10          DFT('none')
     A            MGRNBR         3
     A

Notes:

  1. Relative file numbers must be specified on the JOIN keyword because the same file name is specified twice on the JFILE keyword. Relative file number 1 refers to the first physical file specified on the JFILE keyword, 2 refers to the second, and so forth.

  2. With the same physical files specified on the JFILE keyword, the JREF keyword is required for each field specified at the field level.

Assume the following records are contained in PF1:
Example of a Record

The program reads the following logical file records:
Example of a Record

Note that a record is returned for the manager name of Sue because the JDFTVAL keyword was specified. Also note that the value none is returned because the DFT keyword was used on the Name field in the PF1 physical file.


[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]