Use this join-level keyword to identify which pair of files are joined by the join specification in which you specify this keyword.
JOIN(from-file to-file)
This keyword is valid only for join logical files.
You can use file names or relative file numbers to indicate which files are to be joined. You must specify a relative file number if the same file is specified more than once on the JFILE keyword.
If you specify file names, you must select files that you have specified only once on the JFILE keyword. On each JFILE keyword, the from file must occur before the to file.
The from-file number must always be less than the to-file number.
Special rules apply to the order in which you specify from and to files. See example 3 in this topic for details.
In a join logical file, each secondary file can be a to file only once.
There must be one join specification for each secondary file specified on the JFILE keyword. Therefore, at least one join specification is required in a join logical file.
You can specify the JOIN keyword only once within a join specification.
The following examples show how to specify the JOIN keyword.
|...+....1....+....2....+....3....+....4....+....5....+....6....+....7....+....8 00010A R RECORD1 JFILE(PFA PFB PFC) 00020A J JOIN(PFA PFB) 00030A JFLD(NAME1 NAME2) 00040A J JOIN(PFA PFC) 00050A JFLD(NAME1 NAME3) 00060A NAME1 A
In this example, PFA is joined to PFB and also to PFC.
The following example shows how to specify JOIN using relative file numbers.
|...+....1....+....2....+....3....+....4....+....5....+....6....+....7....+....8 00010A R RECORD1 JFILE(PFA PFB PFC) 00020A J JOIN(1 2) 00030A JFLD(NAME1 NAME2) 00040A J JOIN(1 3) 00050A JFLD(NAME1 NAME3) 00060A NAME1 A
Example 2 is equivalent to example 1. PFA is the first physical file specified on the JFILE keyword and has relative file number 1. PFB and PFC are the second and third files specified on the JFILE keyword. PFB has relative file number 2, and PFC relative file number 3.
The following example shows the order of associated physical files.
|...+....1....+....2....+....3....+....4....+....5....+....6....+....7....+....8 00010A R J3 JFILE(VENDORS PARTS PARTWARE + 00020A WAREHOUSE 1 00030A J JOIN(1 2) 2 00040A JFLD(VNBR VNUM) 00050A J JOIN(2 3) 3 00060A JFLD(PNBR PNBR) 00070A J JOIN(3 4) 3 00080A JFLD(WNBR WNBR) 00090A VNAME 00100A VAD1 00110A VAD2 00120A PNBR JREF(2) 00130A WNBR JREF(4) 00140A BIN 00150A QOH A
The join logical file in this example is based on four physical files. The VENDORS file, which is specified first on the JFILE keyword, is the primary file and has relative file number 1. The PARTS, PARTWARE, and WAREHOUSE files are secondary files. PARTS has relative file number 2, PARTWARE relative file number 3, and WAREHOUSE relative file number 4.
J JOIN(VENDORS PARTS) J JOIN(PARTS PARTWARE) J JOIN(PARTWARE WAREHOUSE)
J JOIN(1 2) J JOIN(2 3) J JOIN(2 4)
However, a file can be specified as a to file only once.