Specify the key field (example 1)

In this example, a logical file views records of two physical files through two different record formats: CLSHST (class history) and JOBHST (job history).

In the logical file, the records from the two physical files can be merged together and sequenced by employee identification number (EMPNBR) by specifying EMPNBR in key position 1.

Figure 1. Specify the key field (example 1)
|...+....1....+....2....+....3....+....4....+....5....+....6....+....7....+....8
00010A          R CLSHST                    PFILE(CLSHSTP)
00020A          K EMPNBR  1
00030A          K CLSDTE  2
00040A*
00050A          R JOBHST                    PFILE(JOBHSTP)
00060A          K EMPNBR  1
00070A          K JOBDTE  2
     A
Record format Key positions  
  1 2
CLSHST EMPNBR CLSDTE
JOBHST EMPNBR JOBDTE

All records that have the same key value for EMPNBR pertain to the same employee. To merge and sequence all records for a given employee into a single history of classes and job assignments, specify CLSDTE (date of class) and JOBDTE (date of job assignment) in key position 2 for the two record formats, as shown in the Using *NONE in the key field when creating a DDS file topic.

Suppose that the job assignment dates and class dates are the dates (month/year) that the class or assignment started. Records for three students are retrieved in the following order:

EMPNBR CLSDTE JOBDTE Description
1005 3/79   Completed class
1005 4/79   Left to begin new job
1005   4/79 Completed job
1005 6/79   Completed class
1006   1/79 Completed job
1006   2/79 Completed job
1006 3/79   Completed class
1006 5/79   Transferred to new location
1007   1/79 Completed job
1007   4/79 Completed job
1007   7/79 Completed job
1007 8/79   Left because of illness

The above report provides a continuous history for each student.

Related concepts
Use *NONE in the key field when creating a DDS file