Now i need to compare entire record two input files and write the matched records in one file and un matched records in other file using SORT. There is no matching criteria.
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
somapradeep1 wrote:
Hi,
I have two files with 300 LRECL each.Now i need to compare entire record two input files and write the matched records in one file and un matched records in other file. There is no matching criteria.
If all of the above is really true, you have a bit of a pickle.
So, let's assume you are relying on the sequence of the two files for your matching criteria.
Have you searched the forum for examples that might help?
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
Quote:
There is no matching criteria.
You can't do a compare if there are no matching criteria.
Are you trying to compare record 1 from file1 with record 1 from file 2, record 2 from file1 with record 2 from file2, etc? If so your matching criteria would be record by record. If that's not your criteria, then you need to define your criteria for comparing records before anyone can help you.
Since both the files have same RECFM and LRECL, this can also be done without joinkeys, but the solution using joinkeys will be easier to maintain and understand.
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
somapradeep, you have still not made things very clear.
This one works without sorting the files. No idea if that matters to you. Depends if you have files which are both logically and physically the same, or just logically the same (order does not matter).
SURPLUS1 and SURPLUS2 are just in case you have more records on one file than the other. SORTOUT will contain the REFORMAT records, so if you have items on MISMATCH you can look at them in context, if necessary. MISMATCH also contains the REFORMAT records.
Hi,
I have two files with 300 LRECL each.Now i need to compare entire record two input files and write the matched records in one file and un matched records in other file. There is no matching criteria.
Other than OP having 300 byte files as opposed to 80 byte, with this approach, you are assuming that both the files are in sorted order and OP wants to compare record by record (1st record of file1 with 1st record of file2), which is not the case. Atleast that's not what OP has mentioned.
If the files are in sorted order already (which I don't see OP has mentioned anywhere), you could always give SORTED,NOSEQCK to the solution I provided and ? will take care of the rest. Also, MISMATCH file in this situation, seem to be double the size of input file+2 bytes. Not sure if that is required as well.
Just my 2 cents... You probably don't need SURPLUS1 and SURPLUS2 because these are true unmatched records.
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
I tested with 80. Not beyond the wit of TS/OP to change to 300, and the rest which relate to 80. I nearly did it with SYMNAMES to make the process of changing easier...
As I explained, the MISMATCH and the SORTOUT are intended to have the REFORMAT records on, just handy to look at what mismatches. If there are mismatches, you can easily see the context. SURPLUS1 and SURPLUS2 are just to provide a quick check on the fiels containing the same number of records. Any or all of these could be changed or excluded with ease.
The idea with the sequence numbers is that it deals with two files whose contents are equal (or to be tested as so), per record, but which are not in sorted order.
We don't know from TS/OP whether their files are in order, need to be in order for comparison, or need to be compared "as is",without being sorted. I believe yours covers the first two, and mine the last.
If your code is used for the last, the files might compare clean, whereas records which are out of order between the two files will be missed as mismatching.
That's what this was about:
Quote:
This one works without sorting the files. No idea if that matters to you. Depends if you have files which are both logically and physically the same, or just logically the same (order does not matter).
We don't know. If the files must be sorted to compare, according to TS/OPs non-information so far, then they must. If they mustn't be sorted, then they mustn't.
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
This is basically the same as my previous, but with SYMNAMES and an extra step.
The new step takes a PARM indicating the record-length. No further changes are needed to compare fixed-length records up to about 1/2 maximum record size. The sequence number allows eight digits, so up-to-but-not-including 100million records.
The REFORMAT record now contains the sequence number. The match indicator is no longer included if it is obvious from the file the record is on.
SURPLUS1, SURPLUS2, SORTOUT, MISMATCH and even MATCH can easily be removed or amended as needed by the user.
The reason for including them was wondering why TS/OP didn't want to use a file-comparison product. So, if I ddn't want to use a file-comparison product, it would be because I could customise it more, not less :-)