Tuesday, February 1, 2011

Sort - Copy records from two different files to single fileusinf Join Key

//STEP001  EXEC  PGM=SORT                                              
//SORTJNF1 DD  DSN=TCTCN.CN2030WT.DISPTBL.APR15,                       
//             DISP=SHR                                                
//SORTJNF2 DD  DSN=TCCCN.CN2030WP.CALLTBL.APR15,                       
//             DISP=SHR                                                
//SORTOUT  DD  DSN=TCCCN.CN2030WP.PREVWEEK.CALLTBL.JOIN.APR08,         
//             DISP=(,CATLG,DELETE),                                   
//             UNIT=SYSDA,                                             
//             SPACE=(CYL,(100,50),RLSE)                               
//SYSOUT   DD  SYSOUT=*                                                
//SYSIN    DD  *                                                       
  SORT FIELDS=(1,10,CH,A)                                              
  JOINKEYS FILE=F1,FIELDS=(7,4,A)                                      
  JOINKEYS FILE=F2,FIELDS=(7,4,A)                                      
  REFORMAT FIELDS=(F2:1,1182,F1:1183,1084)
                             
//*******************************************************************  

Join fields of different files into a single file
1. Sort the file, if it has to be in any specific order   SORT FIELDS=(1,10,CH,A) 
2. Have a field in common in both files in same position. If the file has some position in common or create a field with common values in both files. Here in this two files, position 7 has 4 chars in common in both files. JOINKEYS FILE=F2,FIELDS=(7,4,A)  
3. REFORMAT - will join both files. Here from input file F2, characters from 1 upto length 1182 is copied to output' s 1 - 1182 position. then from input file F1, characters from 1183 upto length 1084 characters is copied to output files position 1183.

No comments:

Post a Comment