|
View previous topic :: View next topic
|
| Author |
Message |
Time2Live
New User

Joined: 27 Apr 2005 Posts: 43 Location: United States
|
|
|
|
Would it be possible to have two output files with two different sorts? Maybe using IF/ELSE statements? Basically what we need is this:
| Code: |
//SORTIN DD DSN=AAAAAAAAAAAAA
//SORTOF1 DD DSN=BBBBBBBBBBBBB
//SORTOF2 DD DSN=CCCCCCCCCCCCC
//SYSIN DD *
SORT FIELDS=(1,10,CH,A)
OUTFIL FILES=1,INCLUDE=(1,2,CH,NE,C'89')
SORT FIELDS=(11,15,CH,D)
OUTFIL FILES=2,INCLUDE=(1,2,CH,EQ,C'89') |
there is a 3rd file too with the same sort as the first one. Thank you in advance for any suggestions.  |
|
| Back to top |
|
 |
Phrzby Phil
Senior Member
Joined: 31 Oct 2006 Posts: 1056 Location: Richmond, Virginia
|
|
|
|
| Why not just try it? |
|
| Back to top |
|
 |
Joerg.Findeisen
Senior Member

Joined: 15 Aug 2015 Posts: 1448 Location: Bamberg, Germany
|
|
|
|
| I would propose using ICETOOL in this case. |
|
| Back to top |
|
 |
Rohit Umarjikar
Global Moderator

Joined: 21 Sep 2010 Posts: 3112 Location: NYC,USA
|
|
| Back to top |
|
 |
sergeyken
Senior Member

Joined: 29 Apr 2008 Posts: 2290 Location: USA
|
|
|
|
| Time2Live wrote: |
Would it be possible to have two output files with two different sorts? Maybe using IF/ELSE statements? Basically what we need is this:
| Code: |
SORT FIELDS=(1,10,CH,A)
OUTFIL FILES=1,INCLUDE=(1,2,CH,NE,C'89')
SORT FIELDS=(11,15,CH,D)
OUTFIL FILES=2,INCLUDE=(1,2,CH,EQ,C'89') |
there is a 3rd file too with the same sort as the first one. Thank you in advance for any suggestions.  |
Since you asked about ANY suggestion, I would also recommend to filter-out unneeded records before SORT operation (as INCLUDE COND= statement), rather than after SORT (as OUTFIL INCLUDE= parameter).
This doesn't matter when playing in a sandbox with tiny test data, but it may become critical with real production data; the run time may change significantly, especially when >50% of input data need to be excluded. |
|
| Back to top |
|
 |
Time2Live
New User

Joined: 27 Apr 2005 Posts: 43 Location: United States
|
|
|
|
Thank you for all your advice. We were able to accomplish what we needed with ICETOOL like this. Then we merged the 3 files back together into 1 file with correct sort.
| Code: |
//S1 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN DD DSN=INPUT FILE
//OUT1 DD DSN=OUTPUT FILE1
//OUT2 DD DSN=OUTPUT FILE2
//OUT3 DD DSN=OUTPUT FILE3
//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,10,CH,A)
INCLUDE COND=(1,2,CH,LT,C'89')
/*
//CTL2CNTL DD *
SORT FIELDS=(11,15,CH,A)
INCLUDE COND=(1,2,CH,EQ,C'89')
/*
//CTL3CNTL DD *
SORT FIELDS=(1,10,CH,A)
INCLUDE COND=(1,2,CH,GT,C'89')
/*
|
|
|
| Back to top |
|
 |
sergeyken
Senior Member

Joined: 29 Apr 2008 Posts: 2290 Location: USA
|
|
|
|
Just to maintain clarity of the code itself, I recommend to place the statements in the order they are really applied:
| Code: |
INCLUDE COND=(1,2,CH,LT,C'89')
SORT FIELDS=(1,10,CH,A) |
|
|
| Back to top |
|
 |
Joerg.Findeisen
Senior Member

Joined: 15 Aug 2015 Posts: 1448 Location: Bamberg, Germany
|
|
|
|
One SORT can be avoided, just in case..
| Code: |
//TOOLIN DD *
SORT FROM(IN) USING(CTL1)
SORT FROM(IN) TO(OUT2) USING(CTL2)
/*
//CTL1CNTL DD *
SORT FIELDS=(1,10,CH,A)
OUTFIL FNAMES=(OUT1),
INCLUDE=(1,2,CH,LT,C'89')
OUTFIL FNAMES=(OUT3),
INCLUDE=(1,2,CH,GT,C'89')
/*
//CTL2CNTL DD *
INCLUDE COND=(1,2,CH,EQ,C'89')
SORT FIELDS=(11,15,CH,A)
/* |
|
|
| Back to top |
|
 |
Rohit Umarjikar
Global Moderator

Joined: 21 Sep 2010 Posts: 3112 Location: NYC,USA
|
|
|
|
| Quote: |
| Then we merged the 3 files back together into 1 file with correct sort. |
It’s always recommended to share with us the entire requirements as one may suggest you better solution or approach than splitting into three output and merge again later. |
|
| Back to top |
|
 |
sergeyken
Senior Member

Joined: 29 Apr 2008 Posts: 2290 Location: USA
|
|
|
|
With some speeding-up:
| Code: |
//TOOLIN DD *
SORT FROM(IN) USING(CTL1)
SORT FROM(IN) TO(OUT2) USING(CTL2)
/*
//CTL1CNTL DD *
INCLUDE COND=(1,2,CH,NE,C'89') - not used in OUT1/OUT3
SORT FIELDS=(1,10,CH,A)
OUTFIL FNAMES=(OUT1),
INCLUDE=(1,2,CH,LT,C'89')
OUTFIL FNAMES=(OUT3),
INCLUDE=(1,2,CH,GT,C'89')
/*
//CTL2CNTL DD *
INCLUDE COND=(1,2,CH,EQ,C'89')
SORT FIELDS=(11,15,CH,A)
/* |
|
|
| Back to top |
|
 |
Joerg.Findeisen
Senior Member

Joined: 15 Aug 2015 Posts: 1448 Location: Bamberg, Germany
|
|
|
|
| sergeyken wrote: |
With some speeding-up: |
Details  |
|
| Back to top |
|
 |
Joerg.Findeisen
Senior Member

Joined: 15 Aug 2015 Posts: 1448 Location: Bamberg, Germany
|
|
|
|
| It would be really interesting what happens after the split with the data. When just merging together again, that process can be simplified. |
|
| Back to top |
|
 |
Rohit Umarjikar
Global Moderator

Joined: 21 Sep 2010 Posts: 3112 Location: NYC,USA
|
|
|
|
| In fact you can do first SORT And produce three outputs in first step , code second step to do second SORT - more efficient as second step is sorting only selected records as compared to do entire list in earlier approach. |
|
| Back to top |
|
 |
sergeyken
Senior Member

Joined: 29 Apr 2008 Posts: 2290 Location: USA
|
|
|
|
| Rohit Umarjikar wrote: |
| In fact you can do first SORT And produce three outputs in first step , code second step to do second SORT - more efficient as second step is sorting only selected records as compared to do entire list in earlier approach. |
Rather than double sorting of unneeded group of records the simple filtering-out of unused records seems to be more effective, isn’t it? |
|
| Back to top |
|
 |
Rohit Umarjikar
Global Moderator

Joined: 21 Sep 2010 Posts: 3112 Location: NYC,USA
|
|
|
|
| It depends on the volume to compare what really works better. Let’s leave it here until TS really care about it. Thanks |
|
| Back to top |
|
 |
|
|
 |
All times are GMT + 6 Hours |
|