Example 9: Using defaults for missing records from secondary files

 

This example shows how to use the default value for a missing join field in a secondary file to join to the other secondary file.

If the DFT keyword is specified in the secondary file, the value specified for the DFT keyword is used in the logical file.

The data description specifications (DDS) for the files are shown as follows:

JLF
|...+....1....+....2....+....3....+....4....+....5....+....6....+....7....+....8
     A                                      JDFTVAL      A          R JRCD                      JFILE(PF1 PF2 PF3)
     A          J                           JOIN(PF1 PF2)
     A                                      JFLD(NAME NAME)
     A          J                           JOIN(PF2 PF3)
     A                                      JFLD(TELEPHONE TELEPHONE)
     A            NAME                      JREF(PF1)
     A            ADDR      A            TELEPHONE                 JREF(PF2)
     A            LOC      A  

PF1 |...+....1....+....2....+....3....+....4....+....5....+....6....+....7....+....8 A R RCD1 A NAME 20 A ADDR 40 A COUNTRY 40 A

PF2 |...+....1....+....2....+....3....+....4....+....5....+....6....+....7....+....8 A R RCD2 A NAME 20 A TELEPHONE 8 DFT('999-9999') A

PF3 |...+....1....+....2....+....3....+....4....+....5....+....6....+....7....+....8 A R RCD3 A TELEPHONE 8 A LOC 30 DFT('No location assigned') A

Assume that PF1, PF2, and PF3 have the following records.

Table 1. Physical file 1 (PF1)
Name Address Country
Anne 120 1st St. USA
Doug 40 Pillsbury Canada
Mark 2 Lakeside Dr. Canada
Sue 120 Broadway USA

Table 2. Physical file 2 (PF2)
Name Telephone
Anne 555–1234
Doug 555–2222
Sue 555–1144

Table 3. Physical file 3 (PF3)
Telephone Location
555–1234 Room 312
555–2222 Main lobby
999–9999 No telephone number

With JDFTVAL specified in the join logical file, the program reads the following logical file records.

Table 4. Join logical file (JLF)
Name Address Telephone Location
Anne 120 1st St. 555–1234 Room 312
Doug 40 Pillsbury 555–2222 Main lobby
Mark 2 Lakeside Dr. 999–9999 No telephone number
Sue 120 Broadway 555–1144 No location assigned
In this example, complete data is found for Anne and Doug. However, part of the data is missing for Mark and Sue.

 

Parent topic:

Setting up a join logical file