JDFTVAL (Join Default Values) Keyword for Physical and Logical Files--Example

Figure 45 shows how to specify the JDFTVAL keyword.

Figure 45. Specifying the JDFTVAL Keyword

|...+....1....+....2....+....3....+....4....+....5....+....6....+....7....+....8
00010A                                      JDFTVAL
00020A          R RECORD1                   JFILE(PF1 PF2)
00030A          J                           JOIN(PF1 PF2)
00040A                                      JFLD(NAME NAME)
00050A            NAME                      JREF(1)
00060A            ADDR
00070A            BAL
     A

PF1 is the primary file and PF2 is a secondary file. Assume that PF1 and PF2 have the following records:

PF1 NAME ADDR PF2 NAME BAL
Anne 120 1st St. Anne 5.00
Doug 40 Pillsbury Doug 6.50
Mark 2 Lakeside Dr. Sue 2.00
Sue 120 Broadway

With JDFTVAL specified in the join logical file, the program reads the following records (shown in arrival sequence):

NAME ADDR BAL
Anne 120 1st St. 5.00
Doug 40 Pillsbury 6.50
Mark 2 Lakeside Dr. 0.00
Sue 120 Broadway 2.00

Without JDFTVAL specified in the join logical file, the program can read only three records (no record is found for Mark).

In this example, if you specified JREF(2) instead of JREF(1), the records returned to the program would be different, as follows:

NAME ADDR BAL
Anne 120 1st St. 5.00
Doug 40 Pillsbury 6.50

2 Lakeside Dr. 0.00
Sue 120 Broadway 2.00