Page 1 of 1

Comparing two files with unmatching records written to file

PostPosted: Tue Jan 18, 2011 8:43 pm
by Praveen433
Hi ,
Please help me in achieving the following criteria
There are two files with same record layout. The first two fields will act as a key(these two fields are common in both files), and the requirement is to compare the remaining fields of those two similar records. If any field is different then the output file should be written with the key fields followed by the mismatch field Number. The output file should contain records which have mismatch fields.

It looks like this
File 1:
                 1       2      3       4       5
Record 1: ABC   XYZ   SSS   AAA   BBB
Record 2: PQR   CBA   EEE  OOO   CCC
Record 3: EPF   ETR   UUU   JJJ   GGG

File 2:
                  1       2      3       4       5   
Record 1: ABC   XYZ    SSS   PPP   BBB
Record 2: PQR   CBA   EEE  OOO   CCC
Record 3: EPF   ETR   MMM   JJJ   QQQ



Output File:
Record 1: ABC   XYZ  4
Record 2: EPF   ETR  3  5


Any change in achieving the requirement is always welcome.
My main requirement is to get the field names which are not matching.

Re: Comparing two files with unmatching records written to f

PostPosted: Wed Jan 19, 2011 2:10 am
by NicC
Q. Can either file have duplicates? If they can, then what is the criteria?

I sus pect that a sort product may have the ability to do what you want. Certainly you could use a programming language to do it. You CANNOT do it with JCL (although JCL could be used to present your solution to the machine for processing).

Re: Comparing two files with unmatching records written to f

PostPosted: Wed Jan 19, 2011 2:16 am
by dick scherrer
Hello,

Which sort product is used on your system?

As NicC mentioned, this could easily be done with a bit of your own code.