Posted: Sun Feb 27, 2011 12:27 pm Post subject: Match & Replace
hi,
I've two files FILE1 and FILE2. LRECL=80 for both the files. I've to compare the two files on the first 10bytes & merge the records, write the records to FILE3. if the record exists only in FILE1 or only in FILE2, then write it to FILE3. If a record exist in both the files(first 10 bytes might match,but other fields will have different values), then copy data from FILE2 & write to FILE3. please note that first 10bytes can have duplicates.
for eg.,
data in FILE1:
1111111111 aaaaaaa
1111111111 bbbbbbb
2222222222 cccccccc
data in FILE2:
1111111111 xxxxxxxx
2222222222 yyyyyyyy
3333333333 zzzzzzzzz
Kolusu,
thanks for your time, but I'm not getting unmatched records from INA file. I need all unmatched records also from both INA & INB files and if a match is found then i should copy the record from INB file to the output.
for eg:
INA file:
1111111111 aaaaaaaaaa
1111111111 bbbbbbbbbb
2222222222 ccccccccccc
2222222222 dddddddddd
4444444444 eeeeeeeeee
My output file should look like:
1111111111 xxxxxxxxxx (since i have a match in INA & INB for first 10 bytes, 1111111111 vvvvvvvvvv copy the data from INB. ignore record from INA)
2222222222 yyyyyyyyyy
3333333333 zzzzzzzzzzz (unmatched record from file2)
4444444444 eeeeeeeeee (unmatched record from file1)
The file should be sorted on first 10bytes and both INA & INB files can have duplicates in the first 10 bytes.
Joined: 26 Nov 2002 Posts: 12375 Topics: 75 Location: San Jose
Posted: Tue Mar 01, 2011 9:17 am Post subject:
koolspark,
Did you copy the control cards as is? If you did and still not get the desired results, then I would like to see the complete sysout from the job
Quote:
1111111111 xxxxxxxxxx (since i have a match in INA & INB for first 10 bytes, 1111111111 vvvvvvvvvv copy the data from INB. ignore record from INA)
In your output you show only 1 record for match and what exactly do I need to copy from the VVVVVVV record? _________________ Kolusu
www.linkedin.com/in/kolusu
along with this, i need to copy all unmatched rows from both the files INA & INB.
in simple, my output file should contain all unmatchted rows from both INA & INB files and matched rows from INB file.
Joined: 26 Nov 2002 Posts: 12375 Topics: 75 Location: San Jose
Posted: Tue Mar 01, 2011 11:27 am Post subject:
koolspark,
You did not answer my question. Did you copy the control cards as is and if so what is the result? Why aren't you showing the sysout from the run?
You change your requirements with every post. Now you want the duplicates from file 2? I can't be providing solutions with a moving target.
If you require the duplicates from file 2 then remove the JNF2CNTL statement which removes the duplicates. What happens to the non-match duplicates from file 1?
kolusu,
I'm really sorry failing to put forward my requirement clearly. with your first solution, i was missing the unmatched records from the first file in my output. also, i was not getting the duplicates from file2 in the output. I needed all the unmatched unique/duplicates from both the files plus the matched unique/duplicate records from file2.
for eg., if i have 10 records for key 1111111111 in file1 and 2 records for the same key 1111111111 in file2 then my output should have the 2 records from file2. It should not copy any of the 10 records from file1.
I'm out of office and don't have access to mainframe, so i'm not able to post the sysout from the job run.
once again thank you verymuch for the support you are providing to the mainframe community..
Joined: 26 Nov 2002 Posts: 12375 Topics: 75 Location: San Jose
Posted: Thu Mar 17, 2011 2:48 pm Post subject:
koolspark,
I am not sure as to what kind help you are looking for because you seem to change the requirements as you please.
The following DFSORT JCL will give you the desired results. I assumed that your input is already sorted on the key in pos 1 thru 10 bytes. If it is not then you need an additional pass to get the information. Let me know if that is the case and I will show you a different solution.
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum