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 chart shows how you can join a physical file to itself:
The join logical file (JLF) contains Employee number, Name, and Manager's name. The physical file (PF1) contains Employee number, Name, and Manager's employee number. The following example shows the data description specifications (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
Assume that the following records are contained in PF1.
Employee number | Name | Manager's employee number |
---|---|---|
235 | Anne | 440 |
440 | Doug | 729 |
500 | Mark | 440 |
729 | Sue | 888 |
The program reads the following logical file records.
Employee number | Name | Manager's name |
---|---|---|
235 | Anne | Doug |
440 | Doug | Sue |
500 | Mark | Doug |
729 | Sue | none |