Page 1 of 1

SORT and split files on condition.

PostPosted: Tue Mar 05, 2013 12:25 am
by shankar_at
Hello,

I did not find exact matching post in this forum, so posting my question (sorry if similar post is hiding somewher).

I want to sort a file into multiple files in the SAME SYSIN DD *, each is based on differnet sort condition.

example, (SORT FIELDS = (1,3,CH,A) ===== want result in file 1
(SORT FIELDS = (5,9,CH,A) ===== want result in file 2
(SORT FIELDS = (15,5,CH,A) ==== " in file 3

I have tried couple of options thru google search, but its not working. I can do this in 3 simple steps but just wanted to know if there is any way to do it in single step.

Can someone help me on this.

Re: SORT and split files on condition.

PostPosted: Tue Mar 05, 2013 2:56 am
by skolusu
shankar_at wrote:Hello,

I did not find exact matching post in this forum, so posting my question (sorry if similar post is hiding somewher).

I want to sort a file into multiple files in the SAME SYSIN DD *, each is based on differnet sort condition.

example, (SORT FIELDS = (1,3,CH,A) ===== want result in file 1
(SORT FIELDS = (5,9,CH,A) ===== want result in file 2
(SORT FIELDS = (15,5,CH,A) ==== " in file 3

I have tried couple of options thru google search, but its not working. I can do this in 3 simple steps but just wanted to know if there is any way to do it in single step.

Can someone help me on this.


I never understood this fascination for a single step. You cannot have 3 different sort on a single pass of data. However you can code a single ICETOOL step which does 3 passes of data (quite similar to 3 steps) and get you the desired results. What exactly is the problem with 3 steps?

Re: SORT and split files on condition.

PostPosted: Tue Mar 05, 2013 3:42 am
by shankar_at
hello,
There is no problem with 3 steps, just was curius to know if there is any sort card which does in single step.. Looks like we cannot do in single step..
thanks for the reply...

Re: SORT and split files on condition.

PostPosted: Tue Mar 05, 2013 3:45 am
by enrico-sorichetti
what counts from an overall performance point of view
is not the number of steps, but the number of passes over the input data
since the SORT is done over 3 different fields, 3 passes are needed.

Re: SORT and split files on condition.

PostPosted: Tue Mar 05, 2013 3:54 am
by skolusu
shankar_at wrote:hello,
There is no problem with 3 steps, just was curius to know if there is any sort card which does in single step.. Looks like we cannot do in single step..
thanks for the reply...


I guess you haven't read my reply properly. Yes you can do in single step but that would involve 3 passes of data. Performance wise it is quite similar to coding 3 different steps. Here is a single step JCL which will do 3 different sorts.


//STEP0100 EXEC PGM=ICETOOL         
//TOOLMSG  DD SYSOUT=*               
//DFSMSG   DD SYSOUT=*               
//IN       DD *                     
----+----1----+----2----+----3----+--
ZZZ 111111111 GGGGG                 
AAA 555555555 HHHHH                 
DDD 333333333 FFFFF                 
//OUT1     DD SYSOUT=*               
//OUT2     DD SYSOUT=*               
//OUT3     DD SYSOUT=*               
//TOOLIN   DD *                     
  SORT FROM(IN) TO(OUT1) USING(CTL1)
  SORT FROM(IN) TO(OUT2) USING(CTL2)
  SORT FROM(IN) TO(OUT3) USING(CTL3)
//*                                 
//CTL1CNTL DD *                     
  SORT FIELDS=(1,3,CH,A)             
//*                                 
//CTL2CNTL DD *                     
  SORT FIELDS=(5,9,CH,A)             
//*                                 
//CTL3CNTL DD *                     
  SORT FIELDS=(15,5,CH,A)           
//*