How can you identify which records have duplicate keys or other data that is duplicated?

Solution:

If a file has records with duplicate data, there is frequently a need to identify which records contain the duplicates. As long as the data is sorted, this is easily resolved. Use a temporary field to store the value of the prior record, and compare the value in the record to the temporary field.

We could use this technique to identify keys, but let's say there is another field we want to analyze.

Let's take a simple case where we have these records where the key is bytes 1-8 and the field of interest is the 1 byte field that follows:

RECORD 1 A
RECORD 2 A
RECORD 3 B
RECORD 4 C
RECORD 5 D
RECORD 6 D
RECORD 7 D
RECORD 8 E
RECORD 9 E

To get this report:

--------------------------------------------------
KEY DATA DUPFLAG
--------------------------------------------------
RECORD 1 A
RECORD 2 A DATA DUPLICATES RECORD 1
RECORD 3 B
RECORD 4 C
RECORD 5 D
RECORD 6 D DATA DUPLICATES RECORD 5
RECORD 7 D DATA DUPLICATES RECORD 6
RECORD 8 E
RECORD 9 E DATA DUPLICATES RECORD 8
** MK4FT03 TYPE 0 END OF REPORT.