Page 1 of 1

Comparing 2 files using JOIN KEYS

PostPosted: Wed Jan 16, 2013 11:43 pm
by borneng2005
Hi,

Could you please let me know if the below requirement can be accomplished using Join Keys in SORT. Basically, i wanted to compare the key of 1st file with the 2nd file and if the key matches, write records from 2nd file to output. In this case, my key is first 7 bytes from both the input file.


File -1:
1111111xxxx
2222222yyyy
4444444zzzz


File-2:
1111111aaaa
1111111bbbb
1111111cccc
2222222aaaa
2222222bbbb
3333333aaaa
3333333bbbb
4444444aaaa

Output file:
1111111aaaa
1111111bbbb
1111111cccc
2222222aaaa
2222222bbbb
4444444aaaa

Re: Comparing 2 files using JOIN KEYS

PostPosted: Wed Jan 16, 2013 11:54 pm
by skolusu
borneng2005,

use the following DFSORT JCL which will give you the desired results.

//STEP0100 EXEC PGM=SORT                   
//SYSOUT   DD SYSOUT=*                     
//INA      DD *                             
1111111aaaa                                 
1111111bbbb                                 
1111111cccc                                 
2222222aaaa                                 
2222222bbbb                                 
3333333aaaa                                 
3333333bbbb                                 
4444444aaaa                                 
//INB      DD *                             
1111111xxxx                                 
2222222yyyy                                 
4444444zzzz                                 
//SORTOUT  DD SYSOUT=*                     
//SYSIN    DD *                             
  OPTION COPY                               
  JOINKEYS F1=INA,FIELDS=(1,7,A)           
  JOINKEYS F2=INB,FIELDS=(1,7,A)           
  REFORMAT FIELDS=(F1:1,80)                 
//*

Re: Comparing 2 files using JOIN KEYS

PostPosted: Thu Jan 17, 2013 12:16 am
by borneng2005
Hi Kolusu,

Thanks a lot for your quick response. The Sort card works like a charm. :)