Controlling how records are retrieved in a logical file with multiple formats
Key field definitions are required in a logical file with more than one record format.
Each record format can have its own key field definition. The record format key fields can be defined to merge the records from different formats. Each record format does not have to contain every key field in the key.
Consider the following records.
| Record | Order | Cust | Ordate |
|---|---|---|---|
| 1 | 41882 | 41394 | 050688 |
| 2 | 32133 | 28674 | 060288 |
| Record | Order | Line | Item | Qtyord | Extens |
|---|---|---|---|---|---|
| A | 32133 | 01 | 46412 | 25 | 125000 |
| B | 32133 | 03 | 12481 | 4 | 001000 |
| C | 41882 | 02 | 46412 | 10 | 050000 |
| D | 32133 | 02 | 14201 | 110 | 454500 |
| E | 41882 | 01 | 08265 | 40 | 008000 |
- Record 2
- Record A
- Record D
- Record B
- Record 1
- Record E
- Record C
For logical files with more than one record format, you can use the *NONE DDS function for key fields to separate records of one record format from records of other record formats in the same access path. Generally, records from all record formats are merged based on key values. However, if *NONE is specified in DDS for a key field, only the records with key fields that appear in all record formats before the *NONE are merged. When such records are retrieved by key from more than one record format, only key fields that appear in all record formats before the *NONE are used. To increase the number of key fields that are used, limit the number of record formats considered.
The logical file in the following example contains three record formats, each associated with a different physical file:
| Record format | Physical file | Key fields |
|---|---|---|
| EMPMSTR | EMPMSTR | Empnbr (employee number) 1 |
| EMPHIST | EMPHIST | Empnbr, Empdat (employed date) 2 |
| EMPEDUC | EMPEDUC | Empnbr, Clsnbr (class number) 3 |
The DDS for this example is:
|...+....1....+....2....+....3....+....4....+....5....+....6....+....7....+....8
A
A K EMPNBR 1
A
A K EMPNBR 2
A K EMPDAT
A
A K EMPNBR 3
A K *NONE
A K CLSNBR
A
*NONE is assumed for the second and third key fields for EMPMSTR and the third key field for EMPHIST because no key fields follow these key field positions.
The following table shows the arrangement of the records.
| Empnbr | Empdat | Clsnbr | Record format name |
|---|---|---|---|
| 426 | EMPMSTR | ||
| 426 | 6/15/74 | EMPHIST | |
| 426 | 412 | EMPEDUC | |
| 426 | 520 | EMPEDUC | |
| 427 | EMPMSTR | ||
| 427 | 9/30/75 | EMPHIST | |
| 427 | 412 | EMPEDUC |