MVSFORUMS.com A Community of and for MVS Professionals
View previous topic :: View next topic
Author
Message
computer Beginner Joined: 12 Jun 2007 Posts: 64 Topics: 17 Location: Hyderabad
Posted: Tue Jun 23, 2009 8:44 am Post subject: FileA and FileB matching records problem.....
Hi All,
My Requirement is, I want to retrieve all the records present in FileB by matching its a part of it from FileA.
Ex:
FileA(LRECL=6,FB)
12345
22222
11111
FileB(LRECL=80,FB)
.............12345......
.............12345......
.............12345......
.............11111......
.............11111......
.............44444......
.............22222......
(Note: Start Pos:14)
Output:
.............12345......
.............12345......
.............12345......
.............11111......
.............11111......
.............22222......
Thanks in Advance,
Manoj
Back to top
Ram Beginner Joined: 12 Jan 2004 Posts: 53 Topics: 12
Back to top
kolusu Site Admin Joined: 26 Nov 2002 Posts: 12378 Topics: 75 Location: San Jose
Posted: Tue Jun 23, 2009 9:10 am Post subject:
computer,
The following JCL will give you the desired results
Code:
//STEP0100 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//I1 DD *
12345
22222
11111
//I2 DD *
.............12345......
.............12345......
.............12345......
.............11111......
.............11111......
.............44444......
.............22222......
//T1 DD DSN=&&T1,DISP=(MOD,PASS),SPACE=(CYL,(X,Y),RLSE)
//OUT DD SYSOUT=*
//TOOLIN DD *
COPY FROM(I1) USING(CTL1)
COPY FROM(I2) USING(CTL2)
SORT FROM(T1) USING(CTL3)
//CTL1CNTL DD *
OUTFIL FNAMES=T1,BUILD=(14:1,5,80:X,C'$')
//CTL2CNTL DD *
OUTFIL FNAMES=T1,OVERLAY=(81:X)
//CTL3CNTL DD *
SORT FIELDS=(14,5,CH,A),EQUALS
OUTREC IFTHEN=(WHEN=INIT,OVERLAY=(82:SEQNUM,8,ZD,RESTART=(14,5))),
IFTHEN=(WHEN=GROUP,BEGIN=(82,8,ZD,EQ,1),PUSH=(81:81,1))
OUTFIL FNAMES=OUT,BUILD=(1,80),
INCLUDE=(81,1,CH,EQ,C'$',AND,82,8,ZD,GT,1)
//*
_________________ Kolusu
www.linkedin.com/in/kolusu
Back to top
amargulies Beginner Joined: 10 Jan 2007 Posts: 123 Topics: 0
Posted: Tue Jun 23, 2009 10:03 am Post subject:
computer,
Here is a SyncSort for z/OS job that will produce the requested records:
Code: //STEP1 EXEC PGM=SORT
//SORTJNF1 DD *
12345
22222
11111
//SORTJNF2 DD *
.............12345......
.............12345......
.............12345......
.............11111......
.............11111......
.............44444......
.............22222......
//SORTOUT DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//SYSIN DD *
JOINKEYS FILES=F1,FIELDS=(1,5,A)
JOINKEYS FILES=F2,FIELDS=(14,5,A)
REFORMAT FIELDS=(F2:1,80)
SORT FIELDS=COPY
/*
This is the output produced:
Code: .............11111......
.............11111......
.............12345......
.............12345......
.............12345......
.............22222......
If you need the order of the records in the output to match that of the input, let me know and I can modify this code for you. _________________ Alissa Margulies
SyncSort Mainframe Product Services
201-930-8260
zos_tech@syncsort.com
Back to top
computer Beginner Joined: 12 Jun 2007 Posts: 64 Topics: 17 Location: Hyderabad
Posted: Tue Jun 23, 2009 10:23 am Post subject:
Hi,
At first thanks to Kolusu and Amar. But can anybody explain me the concept of JOINKEYS please..............
Never used before.
Thanks in Advance,
Manoj
Back to top
kingo Intermediate Joined: 01 Sep 2006 Posts: 167 Topics: 40 Location: chennai
Posted: Tue Jun 23, 2009 10:48 am Post subject:
Hi Computer,
It is key word in syncsort
Where
Code:
JOINKEYS FILES=F1,FIELDS=(1,5,A)
JOINKEYS FILES=F2,FIELDS=(14,5,A)
The two input files for matching are done a join based on key fields
here keys fields
for file1 it is
And file2
_________________ IF YOU ARE NOT FOCUSSED ON GOAL ALL YOU SEE IS OBSTACLE.
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