Processing Matching Records
Matching records for two or more files are processed in the following
manner:
- Whenever a record from the primary file matches a record from the secondary file, the primary file is processed first. Then the matching secondary file is processed. The record identifying indicator that identifies the record type just selected is on at the time the record is processed. This indicator is often used to control the type of processing that takes place.
- Whenever records from ascending files do not match, the record having the lowest match field content is processed first. Whenever records from descending files do not match, the record having the highest match field content is processed first.
- A record type that has no match field specification is processed immediately after the record it follows. The MR indicator is off. If this record type is first in the file, it is processed first even if it is not in the primary file.
- The matching of records makes it possible to enter data from primary records into their matching secondary records because the primary record is processed before the matching secondary record. However, the transfer of data from secondary records to matching primary records can be done only when look-ahead fields are specified.
Figure 1 through Figure 2 show how records from three files are selected for processing.

The records from the three disk files above are selected in the order indicated by the dark numbers.
| Cycle | File Processed | Indicators On | Reason for Setting Indicator |
|---|---|---|---|
| 1 | PRIMARY | 02 | No match field specified |
| 2 | PRIMARY | 02 | No match field specified |
| 3 | FIRSTSEC | 04 | No match field specified |
| 4 | SECSEC | 05 | Second secondary low; no primary match |
| 5 | PRIMARY | 01, MR | Primary matches first secondary |
| 6 | PRIMARY | 01, MR | Primary matches first secondary |
| 7 | FIRSTSEC | 03, MR | First secondary matches primary |
| 8 | FIRSTSEC | 03 | First secondary low; no primary match |
| 9 | FIRSTSEC | 03 | First secondary low; no primary match |
| 10 | SECSEC | 05 | Second secondary low; no primary match |
| 11 | PRIMARY | 01 | Primary low; no secondary match |
| 12 | PRIMARY | 01, MR | Primary matches second secondary |
| 13 | PRIMARY | 02 | No match field specified |
| 14 | SECSEC | 05, MR | Second secondary matches primary |
| 15 | SECSEC | 05, MR | Second secondary matches primary |
| 16 | SECSEC | 06 | No match field specified |
| 17 | PRIMARY | 01, MR | Primary matches both secondary files |
| 18 | FIRSTSEC | 03, MR | First secondary matches primary |
| 19 | FIRSTSEC | 04 | No match field specified |
| 20 | SECSEC | 05, MR | Second secondary matches primary |
| 21 | FIRSTSEC | 03 | First secondary low; no primary match |
| 22 | PRIMARY | 01, MR | Primary matches both secondary files |
| 23 | FIRSTSEC | 03, MR | First secondary matches primary |
| 24 | FIRSTSEC | 02, MR | First secondary matches primary |
| 25 | SECSEC | 05, MR | Second secondary matches primary |
| 26 | SECSEC | 05, MR | Second secondary matches primary |

