Page 1 of 1

Split a file using SORT--Help

PostPosted: Sat Aug 07, 2010 12:16 pm
by jomythomas
I have a requirement like ,
To split a flat file and store data in different dataset.

Sample Input file format(Length 200)
===================


_w2345asf8790001:170:
A0010067 raj akshay 98648
B0006758 jay rakhinc 67589
_w2345asf8790001:168:
B9874646 ysgd yhnty 78659
u6788689 yiru ruiuu 987777


Out put file 1:should be like this,
_w2345asf8790001:170:
A0010067 raj akshay 98648
B0006758 jay rakhinc 67589


Output file2:shold be
_w2345asf8790001:168:
B9874646 ysgd yhnty 78659
u6788689 yiru ruiuu 987777


Maximum occurance of this header will be 4. like 168, 170, 176, 180
Please let me know How can I achieve this using SORT...
The search criteria can be string '_W' in the begining of each line.
I can confirm that '_W' wont come in file other than headers.

Jo

Re: Split a file using SORT--Help

PostPosted: Mon Aug 09, 2010 9:10 pm
by skolusu
Jomythomas,

The following DFSORT JCL will give you the desired results
//STEP0100 EXEC PGM=SORT   
//SYSOUT   DD SYSOUT=*     
//SORTIN   DD DSN=your input FB 200 byte file,DISP=SHR
//OUT1     DD SYSOUT=*                                             
//OUT2     DD SYSOUT=*                                             
//OUT3     DD SYSOUT=*                                             
//OUT4     DD SYSOUT=*                                             
//SYSIN    DD *                                                   
  SORT FIELDS=COPY                                                 
  INREC IFTHEN=(WHEN=GROUP,BEGIN=(1,2,CH,EQ,C'_W'),PUSH=(201:ID=1))
  OUTFIL FNAMES=OUT1,BUILD=(1,200),INCLUDE=(201,1,ZD,EQ,1)         
  OUTFIL FNAMES=OUT2,BUILD=(1,200),INCLUDE=(201,1,ZD,EQ,2)         
  OUTFIL FNAMES=OUT3,BUILD=(1,200),INCLUDE=(201,1,ZD,EQ,3)         
  OUTFIL FNAMES=OUT4,BUILD=(1,200),INCLUDE=(201,1,ZD,EQ,4)         
//*