IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Compare 2 files & matched records


IBM Mainframe Forums -> JCL & VSAM
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
jmreddymca
Warnings : 1

New User


Joined: 14 Oct 2007
Posts: 29
Location: Bangalore

PostPosted: Tue Nov 13, 2007 3:12 pm
Reply with quote

Hi Friends,

i have 2 files , i want to match those 2 files & matched records i want write in the 3rd file . can you suggest me. i have written cobol program.
But is there any other way to do this
Back to top
View user's profile Send private message
Aaru

Senior Member


Joined: 03 Jul 2007
Posts: 1287
Location: Chennai, India

PostPosted: Tue Nov 13, 2007 3:28 pm
Reply with quote

jmreddy,

Quote:
But is there any other way to do this ??????????


This can be accomplished using SYNC/ICE tool. Do provide some more details so that we can help.

Your input, output, RECFM and all.

Else, search the DFSORT forum for similar topics.
Back to top
View user's profile Send private message
santhosh_kumar

New User


Joined: 31 May 2007
Posts: 4
Location: Chennai

PostPosted: Tue Nov 13, 2007 3:31 pm
Reply with quote

You can use ICETOOL utility for the same.
Could you please provide some more information.
1. File property
2. Matching is done on what condition whether matching fields are at same position on both the files.
3. If fields are matched whether you are writing the matched records in both the input file to output file or any one to the output file.

Sweet,
Santhosh
Back to top
View user's profile Send private message
jmreddymca
Warnings : 1

New User


Joined: 14 Oct 2007
Posts: 29
Location: Bangalore

PostPosted: Tue Nov 13, 2007 4:04 pm
Reply with quote

i have 2 i/p files with FB 80 RECL
I want write that in o/p rec with same properties
file mathcing is done by starting 5 chars
matching records i want to write in 1 o/p fille
Back to top
View user's profile Send private message
murmohk1

Senior Member


Joined: 29 Jun 2006
Posts: 1436
Location: Bangalore,India

PostPosted: Tue Nov 13, 2007 4:06 pm
Reply with quote

Reddy,

Your orignial post and the latest almost conveys the same thing. As suggested, go thru dfsort forum..... it had been discussed many times.
Back to top
View user's profile Send private message
krisprems

Active Member


Joined: 27 Nov 2006
Posts: 649
Location: India

PostPosted: Tue Nov 13, 2007 4:14 pm
Reply with quote

Quote:
i have 2 files , i want to match those 2 files & matched records i want write in the 3rd file . can you suggest me

You can do this using DFSORT/ICETOOL or SYNCSORT/SYNCTOOL.
(mention as to what SORT product your are using?)
Provide the details of the file attributes and show some sample records from i/p and o/p.
Also, do you have duplicate reords in the i/p files? if so how it should be handled?
Back to top
View user's profile Send private message
krisprems

Active Member


Joined: 27 Nov 2006
Posts: 649
Location: India

PostPosted: Wed Nov 14, 2007 8:22 am
Reply with quote

jmreddymca
This ICETOOL JCL works fine, if there are no duplicate records in either of your i/p files
Code:
//*******************************************************
//GETMATCH EXEC PGM=ICETOOL                             
//TOOLMSG  DD SYSOUT=*                                   
//DFSMSG   DD SYSOUT=*                                   
//IN       DD I/P FILE-1(FB/80)                         
//         DD I/P FILE-2 (FB/80)                         
//OUT      DD O/P FILE   (FB/80)                         
//TOOLIN   DD *                                         
 SELECT FROM(IN) TO(OUT) ON(1,5,CH) FIRSTDUP             
/*                                                       
//*                                                     
Back to top
View user's profile Send private message
Binaya

New User


Joined: 03 Jul 2007
Posts: 77
Location: Hyderabad

PostPosted: Wed Nov 14, 2007 10:19 am
Reply with quote

Hi Krisprems,

Just want to know what do you men by "duplicate records in either of your i/p files ".

suppose
INFILE-1:-->
AAAAA12345
AAAAA67896
BBBBB12356

INFILE2-2:--->
AAAAA56879
AAAAA54689
AAAAA12548

The output will be
AAAAA12345
BBBBB12356

Let me know if this is correct or not?
Back to top
View user's profile Send private message
Aaru

Senior Member


Joined: 03 Jul 2007
Posts: 1287
Location: Chennai, India

PostPosted: Wed Nov 14, 2007 10:30 am
Reply with quote

Binaya,

Quote:
Just want to know what do you men by "duplicate records in either of your i/p files ".



If there are duplicate records in file 1 then the sort card of prem would consider that as a matching record and write the first record of the duplicates to the output file 3.

That is not correct and hence Krsprems has assumed that there are no duplicates in the input files.
Back to top
View user's profile Send private message
krisprems

Active Member


Joined: 27 Nov 2006
Posts: 649
Location: India

PostPosted: Wed Nov 14, 2007 11:02 am
Reply with quote

Binaya
In my above ICETOOl JCL, you just provide your INFILE-1(do not concatenate with INFILE2-2), and see what o/p you will get....

The output will be....
AAAAA12345

So with out having the 2nd file for comparison also you are getting this record, this is because you have duplicate within one file itself!!
got it?
Back to top
View user's profile Send private message
Binaya

New User


Joined: 03 Jul 2007
Posts: 77
Location: Hyderabad

PostPosted: Wed Nov 14, 2007 11:52 am
Reply with quote

Yes krisprems..Got it..

But the original question was something different where two files has to be compared and to be written in the output file. This has been discussed earlier in this forum..

Thanks...
Back to top
View user's profile Send private message
Aaru

Senior Member


Joined: 03 Jul 2007
Posts: 1287
Location: Chennai, India

PostPosted: Wed Nov 14, 2007 12:12 pm
Reply with quote

Binaya,

Quote:
But the original question was something different where two files has to be compared and to be written in the output file.


no where it is mentioned abt the actual requirement. Take a look at the earlier posts on this topic where we have asked the exact details of the requirement from the OP. As details were not provided, this JCL was posted.

Even in that JCL, 2 files are compared. Two input files are provided in the IN dd statement. This will work fine when there are no duplicates in the input files.
Back to top
View user's profile Send private message
Binaya

New User


Joined: 03 Jul 2007
Posts: 77
Location: Hyderabad

PostPosted: Wed Nov 14, 2007 12:52 pm
Reply with quote

Aaru,

My JCL step is

//STEP1 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//CON1 DD DSN=TBIS.IM.TEST.FILE5,DISP=SHR
// DD DSN=TBIS.IM.TEST.FILE6,DISP=SHR
//DUPS DD SYSOUT=*
//TOOLIN DD *
SELECT FROM(CON1) TO(DUPS) ON(1,20,CH) FIRSTDUP
/*

FILE5:
33333333333333333333
33333333333333333333
88888888888888888888
44444444444444444444
11111111111111111111
55555555555555555555

FILE6:
55555555555555555555
22222222222222222222
33333333333333333333
99999999999999999999

output:
33333333333333333333
55555555555555555555

Pleae clarify?

Thanks..
Back to top
View user's profile Send private message
Aaru

Senior Member


Joined: 03 Jul 2007
Posts: 1287
Location: Chennai, India

PostPosted: Wed Nov 14, 2007 1:54 pm
Reply with quote

Binaya,

Quote:
Pleae clarify?


In your case, you have 2 files (file 5 with duplicate records and file 6 with unique values). You are concatenating it and selecting the first duplicate based on the values in the first 20 bytes.

You have 33333333 in the output as it is present more than once in the input files. The same case with 555555555.

The problem will arise if there are no 3333333333 in file 6. Your JCl would still write 333333333 in the output (even though it is not present in file6) as there are duplicates in the file5.

This is already explained in the previous posts. Please let me know if you are not convinced.
Back to top
View user's profile Send private message
Binaya

New User


Joined: 03 Jul 2007
Posts: 77
Location: Hyderabad

PostPosted: Wed Nov 14, 2007 2:22 pm
Reply with quote

Aaru,

Convinced..

Thanks
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> JCL & VSAM

 


Similar Topics
Topic Forum Replies
No new posts Write line by line from two files DFSORT/ICETOOL 7
No new posts Compare only first records of the fil... SYNCSORT 7
No new posts Pulling a fixed number of records fro... DB2 2
No new posts Merge two VSAM KSDS files into third ... JCL & VSAM 6
No new posts Joinkeys - 5 output files DFSORT/ICETOOL 7
Search our Forums:

Back to Top