Page 1 of 1

Find records in both files with SORT

PostPosted: Mon May 02, 2011 10:38 pm
by Puffe
Hi there,

I have two files and both are fixed blocked and lrecl=10.

File A (key position 1-5) consists of
KevinDukes
KevinWeaks
MikeyHanks
RickiManta
SteveBould
SteveDavid

File B (key position 6-10) consists of
11111Steve
22222Steve
22222Nelli
33333Ricki
44444Vicki
55555Vicki

What I want to accomplish is to find all records with the same key and they must be in both files.

So the result should be the following records
RickiManta
SteveBould
SteveDavid
11111Steve
22222Steve
33333Ricki

Thanks in advance.

Regards,
Mikael

Re: Find records in both files with SORT

PostPosted: Mon May 02, 2011 11:59 pm
by skolusu
puffe,

Use the following DFSORT/ICETOOL JCL which will give you the desired results.

//STEP0100 EXEC PGM=ICETOOL                                 
//TOOLMSG  DD SYSOUT=*                                     
//DFSMSG   DD SYSOUT=*                                     
//INA      DD *                                             
KEVINDUKES                                                 
KEVINWEAKS                                                 
MIKEYHANKS                                                 
RICKIMANTA                                                 
STEVEBOULD                                                 
STEVEDAVID                                                 
//INB      DD *                                             
11111STEVE                                                 
22222STEVE                                                 
22222NELLI                                                 
33333RICKI                                                 
44444VICKI                                                 
55555VICKI                                                 
//T1       DD DSN=&&OUT,DISP=(,PASS),SPACE=(CYL,(1,1),RLSE)
//OUT      DD SYSOUT=*                                     
//TOOLIN   DD *                                             
  COPY JKFROM TO(T1) USING(CTL1)                           
  SORT FROM(T1) USING(CTL2)                                 
//CTL1CNTL DD *                                             
  JOINKEYS F1=INA,FIELDS=(1,5,A)                           
  JOINKEYS F2=INB,FIELDS=(6,5,A)                           
  REFORMAT FIELDS=(F1:1,10,F2:1,10)                         
  OUTFIL BUILD=(1,10,1,5,/,11,10,16,5)                     
//*                                                         
//CTL2CNTL DD *                                             
  SORT FIELDS=(11,5,CH,A,1,5,CH,A),EQUALS                   
  OUTREC OVERLAY=(11:SEQNUM,3,ZD,RESTART=(1,10))           
  OUTFIL FNAMES=OUT,OMIT=(11,3,ZD,GT,1),BUILD=(1,10)       
/*

Re: Find records in both files with SORT

PostPosted: Tue May 03, 2011 1:12 am
by Puffe
Thanks, but I'm pretty sure our company don't have the right version of ICETOOL where I can use JOINKEYS. Any other suggestion?

Re: Find records in both files with SORT

PostPosted: Tue May 03, 2011 1:25 am
by skolusu
Puffe,

Run the following job and show us the complete sysout which will help us determine the level of DFSORT you have

//STEP0100 EXEC PGM=SORT   
//SYSOUT   DD SYSOUT=*     
//SORTIN   DD *           
A                         
//SORTOUT  DD SYSOUT=*     
//SYSIN    DD *           
  SORT FIELDS=COPY         
//*