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 

FileA and FileB matching records problem.....

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


Joined: 12 Jun 2007
Posts: 64
Topics: 17
Location: Hyderabad

PostPosted: Tue Jun 23, 2009 8:44 am    Post subject: FileA and FileB matching records problem..... Reply with quote

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
View user's profile Send private message
Ram
Beginner


Joined: 12 Jan 2004
Posts: 53
Topics: 12

PostPosted: Tue Jun 23, 2009 8:50 am    Post subject: Reply with quote

Its worth searching the forum before posting the question. Did you check the FAQ's section on JCL/Sort ?

http://mvsforums.com/helpboards/viewtopic.php?t=5399
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Tue Jun 23, 2009 9:10 am    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website
amargulies
Beginner


Joined: 10 Jan 2007
Posts: 123
Topics: 0

PostPosted: Tue Jun 23, 2009 10:03 am    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail
computer
Beginner


Joined: 12 Jun 2007
Posts: 64
Topics: 17
Location: Hyderabad

PostPosted: Tue Jun 23, 2009 10:23 am    Post subject: Reply with quote

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
View user's profile Send private message
kingo
Intermediate


Joined: 01 Sep 2006
Posts: 167
Topics: 40
Location: chennai

PostPosted: Tue Jun 23, 2009 10:48 am    Post subject: Reply with quote

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

Code:


 FIELDS=(1,5,A)

 


And file2

Code:


FIELDS=(14,5,A)


_________________
IF YOU ARE NOT FOCUSSED ON GOAL ALL YOU SEE IS OBSTACLE.
Back to top
View user's profile Send private message Yahoo Messenger
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