Use more than one field to join files (example 2)

You can specify more than one join field to join a pair of files. This example shows the fields in the logical file and the two physical files.


Logical file and two physical files

The join logical file (JLF) has fields Part number, Color, Price, and Quantity on hand. Physical file 1 (PF1) has Part number, Color, Price, and Vendor, while physical file 2 (PF2) has Part number, Color, Quantity on hand, and Warehouse. The data description specifications (DDS) for these files are shown as follows:

JLF
|...+....1....+....2....+....3....+....4....+....5....+....6....+....7....+....8
     A          R JOINREC                   JFILE(PF1 PF2)
     A          J                           JOIN(PF1 PF2)
     A                                      JFLD(PTNBR PTNBR)
     A                                      JFLD(COLOR COLOR)
     A            PTNBR                     JREF(PF1)
     A            COLOR                     JREF(PF1)
     A            PRICE
     A            QUANTOH
     A
 
PF1
|...+....1....+....2....+....3....+....4....+....5....+....6....+....7....+....8
     A          R REC1
     A            PTNBR          4
     A            COLOR         20
     A            PRICE          7  2
     A            VENDOR        40
     A
 
PF2
|...+....1....+....2....+....3....+....4....+....5....+....6....+....7....+....8
     A          R REC2
     A            PTNBR          4
     A            COLOR         20
     A            QUANTOH        5  0
     A            WAREHSE       30
     A

Assume that the physical files have the following records.

Table 1. Physical file 1 (PF1)
Part number Color Price Vendor
100 Black 22.50 ABC Corp.
100 White 20.00 Ajax Inc.
120 Yellow 3.75 ABC Corp.
187 Green 110.95 ABC Corp.
187 Red 110.50 ABC Corp.
190 Blue 40.00 Ajax Inc.
Table 2. Physical file 2 (PF2)
Part number Color Quantity on hand Warehouse
100 Black 23 ABC Corp.
100 White 15 Ajax Inc.
120 Yellow 102 ABC Corp.
187 Green 0 ABC Corp.
187 Red 2 ABC Corp.
190 Blue 2 Ajax Inc.

If the file is processed sequentially, the program receives the following records.

Table 3. Join logical file (JLF)
Part number Color Price Quantity on hand
100 Black 22.50 23
100 White 20.00 15
120 Yellow 3.75 102
187 Green 110.95 0
187 Red 110.50 2
Note: No record for part number 190, color blue, is available to the program, because a match was not found on both fields in the secondary file. Because JDFTVAL was not specified, no record is returned.