Generic File Comparison

The program can be run on any two files with identical file layouts. This will run without any table configuration at all. The key information is derived from the key of the first file specified. This key needs to be unique. The program sorts the files based upon the specified key fields, and the performs a merge sort (aka Matching Records).

The program is called from the command line with the following parameters:

The program call looks like this:

call cp1030c (DTAPRD F0411LE *FIRST DTAQUA F0411LE *FIRST 'Comparison of A/P Files - Testing')

The generated report looks like this:

CP1030                                                Compare/Contrast Files                                                 9/07/06
Page:         1                                  Comparison of A/P Files - Testing                                           9:49:30
Left File:  DTAPRD/F0411LE.*FIRST
Right File: DTAQUA/F0411LE.*FIRST
  RPDOC    RPDCT RPKCO RPSFX RPSFXE FldNam Before                                      After
  ======== ===== ===== ===== ====== ------ ------------------------------------------- -------------------------------------------
  03424416  PV   00110  001    00   RPPYIN                                               0
  03426602  PV   00110  001    00   RPPST    A                                           P
                                    RPAAP            10275                                           0
R 03544881  PV   00000  001    00
L 03544883  PV   00000  001    00          

The image I had in mind while writing this was of someone sitting with two file dumps in front of him (comparing them line by line); one on the left (L) and one on the right (R). All we are doing is automating the comparison. The significance of the report is as follows (by line):

  1. Record 03424416/PV/00110/001/00 exists in both libraries:
  2. Record 03426602/PV/00110/001/00 exists in both libraries:
  3. Record 03544881/PV/00000/001/00 exists in DTAQUA, but not in DTAPRD.
  4. Record 03544883/PV/00000/001/00 exists in DTAPRD, but not in DTAQUA.

A couple of notes:

In addition:

Sometimes we are not interested in comparing *every* field in the file. Audit fields (date created, etc., come to mind). For every field to be excluded, add a record to the file CP1030F. The following is an example when loaded for F0411LE:

 AFRECTYP    AFFLDNAM 
 ----------  ----------                       
 F0411LE     RPUSER                          
 F0411LE     RPPID                           
 F0411LE     RPUPMJ                          
 F0411LE     RPUPMT                          
 F0411LE     RPJOBN                         

The key field is the same as the First File Name.


The following link takes you to the source code, written in beautiful /free ILE/RPG. Both the source and the compiled objects are distributed under a creative commons license.

cp1030.txt - Generic File Comparisonf




Valid HTML 3.2! Creative Commons License

BrilligWare/ chris@pando.org / revised February 2005