IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

[Solved]Possible to have two sort cards on one step?


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Time2Live

New User


Joined: 27 Apr 2005
Posts: 22
Location: United States

PostPosted: Thu Feb 03, 2022 7:11 am
Reply with quote

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. icon_smile.gif
Back to top
View user's profile Send private message
Phrzby Phil

Senior Member


Joined: 31 Oct 2006
Posts: 1036
Location: Richmond, Virginia

PostPosted: Thu Feb 03, 2022 10:03 am
Reply with quote

Why not just try it?
Back to top
View user's profile Send private message
Joerg.Findeisen

Active Member


Joined: 15 Aug 2015
Posts: 940
Location: Bamberg, Germany

PostPosted: Thu Feb 03, 2022 10:31 am
Reply with quote

I would propose using ICETOOL in this case.
Back to top
View user's profile Send private message
Rohit Umarjikar

Global Moderator


Joined: 21 Sep 2010
Posts: 2963
Location: NYC,USA

PostPosted: Thu Feb 03, 2022 5:45 pm
Reply with quote

ibmmainframes.com/about27066.html
It’s three passes anyways , so it doesn’t matter how you do it.
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 1650

PostPosted: Thu Feb 03, 2022 6:33 pm
Reply with quote

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. icon_smile.gif

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
View user's profile Send private message
Time2Live

New User


Joined: 27 Apr 2005
Posts: 22
Location: United States

PostPosted: Thu Feb 03, 2022 9:03 pm
Reply with quote

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
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 1650

PostPosted: Thu Feb 03, 2022 9:15 pm
Reply with quote

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
View user's profile Send private message
Joerg.Findeisen

Active Member


Joined: 15 Aug 2015
Posts: 940
Location: Bamberg, Germany

PostPosted: Thu Feb 03, 2022 9:20 pm
Reply with quote

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
View user's profile Send private message
Rohit Umarjikar

Global Moderator


Joined: 21 Sep 2010
Posts: 2963
Location: NYC,USA

PostPosted: Thu Feb 03, 2022 9:24 pm
Reply with quote

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
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 1650

PostPosted: Thu Feb 03, 2022 9:25 pm
Reply with quote

icon_lol.gif icon_lol.gif icon_lol.gif

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
View user's profile Send private message
Joerg.Findeisen

Active Member


Joined: 15 Aug 2015
Posts: 940
Location: Bamberg, Germany

PostPosted: Thu Feb 03, 2022 9:40 pm
Reply with quote

sergeyken wrote:
icon_lol.gif icon_lol.gif icon_lol.gif

With some speeding-up:

Details icon_biggrin.gif
Back to top
View user's profile Send private message
Joerg.Findeisen

Active Member


Joined: 15 Aug 2015
Posts: 940
Location: Bamberg, Germany

PostPosted: Thu Feb 03, 2022 9:42 pm
Reply with quote

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
View user's profile Send private message
Rohit Umarjikar

Global Moderator


Joined: 21 Sep 2010
Posts: 2963
Location: NYC,USA

PostPosted: Sat Feb 05, 2022 6:06 am
Reply with quote

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
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 1650

PostPosted: Sat Feb 05, 2022 6:52 am
Reply with quote

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
View user's profile Send private message
Rohit Umarjikar

Global Moderator


Joined: 21 Sep 2010
Posts: 2963
Location: NYC,USA

PostPosted: Tue Feb 08, 2022 5:02 am
Reply with quote

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
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts Forcing a step to run (even if abended) JCL & VSAM 7
No new posts JCL SORT to compress the student's de... DFSORT/ICETOOL 7
No new posts step by step trace 4 ISPF dialog call... TSO/ISPF 17
No new posts WER999A - UNSUCCESSFUL SORT 8ED U Ab... SYNCSORT 5
No new posts COBOL Ascending and descending sort n... COBOL Programming 5
Search our Forums:

Back to Top