JOIN (Join) Keyword for Physical and Logical Files--Examples

Figure 52, Figure 53, and Figure 54 show how to specify the JOIN keyword.

Figure 52. Specifying the JOIN Keyword (Example 1)

|...+....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 Figure 52, PFA is joined to PFB and also to PFC.

Figure 53 shows how to specify JOIN using relative file numbers.

Figure 53. Specifying the JOIN Keyword (Example 2)

|...+....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

Figure 53 is equivalent to Figure 52. 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 and have relative file numbers 2 and 3, respectively.

Figure 54 shows the order of associated physical files.

Figure 54. Specifying the JOIN Keyword (Example 3)

|...+....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 Figure 54 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, which are secondary files, have relative file numbers 2, 3, and 4, respectively.

Notice the pattern of numbers specified on the JOIN keywords:

(1)
The first parameter value on the first JOIN keyword (the first from file) must be the primary file.

(2)
The second parameter values specified on the JOIN keywords (to files) must reflect the same order as the secondary files on the JFILE keyword. If file names were specified instead of relative file numbers, they would have to be specified in the following order:
J    JOIN(VENDORS PARTS)
J    JOIN(PARTS PARTWARE)
J    JOIN(PARTWARE WAREHOUSE)

(3)
On each JOIN keyword, the from and to files must be specified in ascending order.
Note:
A file can be specified as a from file more than once. For example, the parameters on the JOIN keywords above could have been specified as follows:
J    JOIN(1 2)
J    JOIN(2 3)
J    JOIN(2 4)

However, a file can be specified as a to file only once.