In this example, consider a logical employee file over five physical
files.
Figure 1. Specify the key field (example 3)|...+....1....+....2....+....3....+....4....+....5....+....6....+....7....+....8
00010A R EMPMST PFILE(EMPMSTP)
00020A K EMPNBR 1
00030A*
00040A R CLSREG PFILE(CLSREGP)
00050A K EMPNBR 1
00060A K CLSDTE 2
00070A*
00080A R CLSHST PFILE(CLSHSTP)
00090A K EMPNBR 1
00100A K CLSDTE 2
00110A*
00120A R JOBHST PFILE(JOBHSTP)
00130A K EMPNBR 1
00140A K *NONE 2
00150A K JOBDTE 3
00160A*
00170A R ACTHST PFILE(ACTHSTP)
00180A K EMPNBR 1
00190A K *NONE 2
00200A K ACTDTE 3
A
Record format |
Key positions |
|
|
|
1 |
2 |
3 |
EMPMST |
EMPNBR |
*NONE |
*NONE |
CLSREG |
EMPNBR |
CLSDTE |
*NONE |
CLSHST |
EMPNBR |
CLSDTE |
*NONE |
JOBHST |
EMPNBR |
*NONE |
JOBDTE |
ACTHST |
EMPNBR |
*NONE |
ACTDTE |
The records are merged and sequenced as follows:
- All records are merged and sequenced by employee number.
- For a given employee, records are sequenced by:
- The master record (of the EMPMST format)
- Records of the CLSREG and CLSHST formats, merged and sequenced together
on values of CLSDTE (key position 2)
- Records of the JOBHST and ACTHST formats, merged together and sequenced
together on values of JOBDTE and ACTDTE (key position 3)
Specifying *NONE in the key definitions achieves this sequencing as
follows:
- *NONE and a field name, CLSDTE, appear in the second key position of the
adjacent formats, CLSHST and JOBHST. This effectively causes a split between
the two formats after the preceding key position (position 1). Records of
formats above the split are merged and sequenced with records of formats below
the split only on values of EMPNBR.
- An implicit *NONE in the second key position of the format EMPMST forces
a similar split.
- With *NONE in key position 2, the JOBHST and ACTHST formats form a set
in which the values of JOBDTE and ACTDTE are compared in order to merge and
sequence records of these two formats only.
The record sequence defined by the previous key specifications
is totally dependent on the order in which the formats are specified. For
example, if JOBHST is specified before CLSHST, key position 2 will read:
*NONE, CLSDTE, *NONE, CLSDTE, *NONE
Here,
the values of CLSDTE within CLSREG will not be sequenced with the values of
CLSDTE within CLSHST, and JOBDTE will not be sequenced with ACTDTE.