MVSFORUMS.com A Community of and for MVS Professionals
View previous topic :: View next topic
Author
Message
me_naveen Beginner Joined: 21 Dec 2007 Posts: 23 Topics: 12
Posted: Wed Feb 13, 2008 6:36 am Post subject: Matching between 2 files and writing into other file
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
vkphani Intermediate Joined: 05 Sep 2003 Posts: 483 Topics: 48
Posted: Wed Feb 13, 2008 7:59 am Post subject:
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
me_naveen Beginner Joined: 21 Dec 2007 Posts: 23 Topics: 12
Posted: Wed Feb 13, 2008 8:25 am Post subject:
Thank You very much Phani...
Thanks,
Nav
Back to top
amargulies Beginner Joined: 10 Jan 2007 Posts: 123 Topics: 0
Posted: Wed Feb 13, 2008 2:32 pm Post subject:
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
me_naveen Beginner Joined: 21 Dec 2007 Posts: 23 Topics: 12
Posted: Fri Feb 15, 2008 7:24 am Post subject:
Hi amargulies,
I have tried this and it works fine.
Thanks alot for your help.
Thanks,
Nav
Back to top
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