How to split dataset using JCL based on a specific field?

88 Views Asked by At

I have a dataset which I need to break into 10 smaller chunks (datasets) based on ID which is unique. The chunks are not supposed to have simillar lenghth. For example ID 1 thru 200 should be in chunk1, ID 201 thru 240 shuld be in chunk2 and etc. I searched a lot and came accrose the following piece of code that didnt work for me

//S1    EXEC  PGM=SORT
//SYSOUT    DD  SYSOUT=*
//SORTIN DD DSN=... input file
//OUT1 DD DSN=...  output file1
//OUT2 DD DSN=...  output file2
//SYSIN    DD    *
  OPTION COPY
  OUTFIL FNAMES=OUT1,INCLUDE=(1,6,PD,LE,200)
FNAMES=OUT2,INCLUDE=(1,6,ch,LE,250&#41

Please help me...

1

There are 1 best solutions below

0
Kolusu On

Soraya,

Use the following DFSORT JCL which shows how to split the input file into multiple output files.

//STEP0100 EXEC PGM=SORT                                           
//SYSOUT   DD SYSOUT=*                                             
//SORTIN   DD *                                                    
 01                                                                
 10                                                                
 99                                                                
225                                                                
151                                                                
240                                                                
200                                                                
201                                                                
//OUT1     DD SYSOUT=*                                             
//OUT2     DD SYSOUT=*                                             
//SYSIN    DD *                                                    
  OPTION COPY                                                      
  OUTFIL FNAMES=OUT1,INCLUDE=(1,3,UFF,LE,200)                      
  OUTFIL FNAMES=OUT2,INCLUDE=(1,3,UFF,GT,200,AND,1,3,UFF,LE,240)   
/*                                                                 

The output for OUT1 file will be

 01
 10
 99
151
200

The output for OUT2 file will be

201
225
240