MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Sorting the resulting file after a sort

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities
View previous topic :: View next topic  
Author Message
misi01
Advanced


Joined: 02 Dec 2002
Posts: 619
Topics: 172
Location: Stockholm, Sweden

PostPosted: Fri Jan 18, 2019 9:01 am    Post subject: Sorting the resulting file after a sort Reply with quote

Just wondering if this can be done in one cycle.
My JCL looks like this
Code:

//SORTIN   DD DISP=SHR,DSN=SIMMIC.DIALTELT.X137U.SYSOUT.PS030
//*                                                           
//SORTOUT  DD DISP=(,CATLG),DSN=SIMMIC.KBN220.SECTIONS       
//*                                                           
//SYSIN    DD *                                               
  INCLUDE COND=(2,19,CH,EQ,C'Processing section ')           
  SORT FIELDS=(1,35,CH,A)                                     
    OUTFIL REMOVECC,NODETAIL,                                 
    SECTIONS=(1,50,                                           
       TRAILER3=(1,35,X,COUNT=(M10,LENGTH=8)))               
  SORT FIELDS=COPY                                           
//*                                                           

My input file contains something like this
Code:

KBN220 VERSION 101213               
START KBN220 KLOCKAN 143050         
Processing section STYR             
Processing section A-INITIERA       
*START AV KBN220*                   
VECKODAG 5                         
Processing section S14-GU-SAT22VA   
Processing section S26-CALL-KAT100 
Processing section S26-CALL-KAT100 
Processing section S26-CALL-KAT100 
Processing section S26-CALL-KAT100 

and my resulting file looks like this ( a summation for each occurrence of unique section names)
Code:

Processing section A-INITIERA             1
Processing section B-BEHANDLA            18
Processing section BA-BEHANDLA-TAB        4
Processing section BBAAA-LKFKOD-ZO       10
Processing section BBAE-TARIFFIERI       10
Processing section BBAEA-BEHANDLA-       27
Processing section BBAF-LAES-TEXTE       15
Processing section BBAG-SKRIV-OMFA       25


All well and good. I appreciate that I could have an extra step in the JCL to sort the output file in descending occurrence, but I'm wondering whether there's a way of including a sort on columns 35-42 (the numbers) so te results are shown in descending order.
_________________
Michael
Back to top
View user's profile Send private message Send e-mail
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12367
Topics: 75
Location: San Jose

PostPosted: Fri Jan 18, 2019 11:24 am    Post subject: Reply with quote

misi01,

Quite simple. Use the trick of Joinkeys and the 2nd file will be a dummy. Since JNF1 is a subtask you can have a init counter of 1 for every record and then sum it up using SUM statement. Once you have the results, then it is a simple SORT on the counter descending on the main task. Something like this

Code:

//STEP0100 EXEC PGM=SORT                                             
//SYSOUT   DD SYSOUT=*                                               
//INA      DD *                                                       
 KBN220 VERSION 101213                                               
 START KBN220 KLOCKAN 143050                                         
 PROCESSING SECTION STYR                                             
 PROCESSING SECTION A-INITIERA                                       
 *START AV KBN220*                                                   
 VECKODAG 5                                                           
 PROCESSING SECTION S14-GU-SAT22VA                                   
 PROCESSING SECTION S26-CALL-KAT100                                   
 PROCESSING SECTION S26-CALL-KAT100                                   
 PROCESSING SECTION S26-CALL-KAT100                                   
 PROCESSING SECTION S26-CALL-KAT100                                   
//INB      DD DUMMY,DCB=(LRECL=80,RECFM=FB,BLKSIZE=27920)             
//SORTOUT  DD SYSOUT=*                                               
//SYSIN    DD *                                                       
  JOINKEYS F1=INA,FIELDS=(1,35,A)                                     
  JOINKEYS F2=INB,FIELDS=(1,35,A)                                     
  JOIN UNPAIRED,F1,ONLY                                               
                                                                     
  SORT FIELDS=(36,4,PD,D)         $ SORT COUNTERS DESCENDING         
                                                                     
  OUTREC BUILD=(01,35,X,                                             
                36,4,PD,M10,LENGTH=8)                                 
//*                                                                   
//JNF1CNTL DD *                                                       
  INCLUDE COND=(2,19,CH,EQ,C'PROCESSING SECTION ')                   
  INREC BUILD=(1,35,              $ KEY                               
               X'0000001C')       $ COUNTER OF 1 IN PACKED FORMAT     
                                                                     
  SUM FIELDS=(36,4,PD)            $ SUM COUNTER                       
//*                                                                   


the output would be something like this
Code:

 PROCESSING SECTION S26-CALL-KAT100        4   
 PROCESSING SECTION A-INITIERA             1   
 PROCESSING SECTION STYR                   1   
 PROCESSING SECTION S14-GU-SAT22VA         1   

_________________
Kolusu - DFSORT Development Team (IBM)
DFSORT is on the Web at:
www.ibm.com/storage/dfsort

www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
misi01
Advanced


Joined: 02 Dec 2002
Posts: 619
Topics: 172
Location: Stockholm, Sweden

PostPosted: Sun Jan 20, 2019 3:20 am    Post subject: Reply with quote

Thanks, I'll try it at work this week
_________________
Michael
Back to top
View user's profile Send private message Send e-mail
misi01
Advanced


Joined: 02 Dec 2002
Posts: 619
Topics: 172
Location: Stockholm, Sweden

PostPosted: Tue Jan 29, 2019 3:30 am    Post subject: Reply with quote

Forgot to get back to you.

Worked a treat, thank you
_________________
Michael
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group