MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Matching between 2 files and writing into other file

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities
View previous topic :: View next topic  
Author Message
me_naveen
Beginner


Joined: 21 Dec 2007
Posts: 23
Topics: 12

PostPosted: Wed Feb 13, 2008 6:36 am    Post subject: Matching between 2 files and writing into other file Reply with quote

Hi,
I have 2 sequential files

FIle1
-----
AAA KING
BBB QUEEN

File2
-----
AAA 2222
BBB 8888
CCC 8789

If we compare file1 with file2 if any matched records found
The output file should look like

Output file
AAA KING 2222
BBB QUEEN 8888

Please help me how could we get it with SORT or ICETOOL Utilities.

Thanks,
Nav
Back to top
View user's profile Send private message
vkphani
Intermediate


Joined: 05 Sep 2003
Posts: 483
Topics: 48

PostPosted: Wed Feb 13, 2008 7:59 am    Post subject: Reply with quote

Naveen,

The below code will give you the desired resluts.

Code:
//S1    EXEC  PGM=ICETOOL                                         
//TOOLMSG   DD  SYSOUT=*                                         
//DFSMSG    DD  SYSOUT=*                                         
//IN1 DD *                                                       
AAA KING                                                         
BBB QUEEN                                                         
//IN2 DD *                                                       
AAA 2222                                                         
BBB 8888                                                         
CCC 8789                                                         
//TMP1 DD DSN=&&TEMP1,DISP=(MOD,PASS),SPACE=(TRK,(5,5)),UNIT=SYSDA
//OUT DD SYSOUT=*                                                 
//TOOLIN DD *                                                     
COPY FROM(IN1) TO(TMP1) USING(CPY1)                               
COPY FROM(IN2) TO(TMP1) USING(CPY2)                               
SPLICE FROM(TMP1) TO(OUT) ON(1,3,CH) WITH(11,5)                   
/*                                                               
//CPY1CNTL DD *                                                   
  OUTREC FIELDS=(1:1,3,5:5,5,11:5X)                               
/*                                                               
//CPY2CNTL DD *                                                   
  OUTREC FIELDS=(1:1,3,11:5,5)                                   
/*


OUT:

Code:
AAA KING  2222
BBB QUEEN 8888
Back to top
View user's profile Send private message Send e-mail
me_naveen
Beginner


Joined: 21 Dec 2007
Posts: 23
Topics: 12

PostPosted: Wed Feb 13, 2008 8:25 am    Post subject: Reply with quote

Thank You very much Phani...


Thanks,
Nav
Back to top
View user's profile Send private message
amargulies
Beginner


Joined: 10 Jan 2007
Posts: 123
Topics: 0

PostPosted: Wed Feb 13, 2008 2:32 pm    Post subject: Reply with quote

If you have SyncSort for z/OS 1.2 or later, here's a SORT application you can use:
Code:

//SORT1  EXEC PGM=SORT                                 
//SORTJNF1 DD DISP=SHR,DSN=FILE1
//SORTJNF2 DD DISP=SHR,DSN=FILE2
//SORTOUT  DD DISP=(NEW,CATLG),DSN=MATCHED.RECORDS
//SYSOUT   DD SYSOUT=*                                       
//SYSIN    DD *                       
   JOINKEYS FILES=F1,FIELDS=(1,3,A)
   JOINKEYS FILES=F2,FIELDS=(1,3,A)
   REFORMAT FIELDS=(F1:1,9,F2:4,5) 
   SORT FIELDS=COPY                 
/*           

This will accomplish the task in a single pass of the data.
_________________
Alissa Margulies
SyncSort Mainframe Product Services
201-930-8260
zos_tech@syncsort.com
Back to top
View user's profile Send private message Send e-mail
me_naveen
Beginner


Joined: 21 Dec 2007
Posts: 23
Topics: 12

PostPosted: Fri Feb 15, 2008 7:24 am    Post subject: Reply with quote

Hi amargulies,
I have tried this and it works fine.

Thanks alot for your help.

Thanks,
Nav
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
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


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group