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

Counting number of records based on a key using SYNCSORT


IBM Mainframe Forums -> JCL & VSAM
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Gnanas N

Active Member


Joined: 06 Sep 2007
Posts: 792
Location: Chennai, India

PostPosted: Thu May 22, 2008 5:30 pm
Reply with quote

My shop is using SYNCSORT.

I use this SYSIN for getting number of records based on a key.

Code:
SORT FIELDS=(80,10,CH,A)           
 OUTFIL REMOVECC,NODETAIL,         
      SECTIONS=(80,10,             
          TRAILER3=(80,10,X,COUNT))


Key value starts at 80 byte and runs for 10 bytes.

But I want to get the records which count is 5.
Please let me know what changes can be done on that SYSIn card.
Hope my query is clear.
Back to top
View user's profile Send private message
Manuneedhi K

Active User


Joined: 07 May 2008
Posts: 115
Location: Chennai

PostPosted: Thu May 22, 2008 5:38 pm
Reply with quote

Are you referring to the number of occurences of the key?

Say key=aaa occurs 10 times and key=bbb occurs 4 times you want to output all the records whose key =aaa ?


Please can you clarify.
Back to top
View user's profile Send private message
Gnanas N

Active Member


Joined: 06 Sep 2007
Posts: 792
Location: Chennai, India

PostPosted: Thu May 22, 2008 6:01 pm
Reply with quote

Thanks for your reply.

These are input records.
Code:
....AAAAAAAAA123...
....AAAAAAAAA123...
....AAAAAAAAA123...
....AAAAAAAAA124...
....AAAAAAAAA123...
....AAAAAAAAA123...
....AAAAAAAAA125...
....AAAAAAAAA125...
....AAAAAAAAA300...
....AAAAAAAAA300...
....AAAAAAAAA300...
....AAAAAAAAA300...
....AAAAAAAAA300...
....AAAAAAAAA500...
....AAAAAAAAA999...


I want output as below.
Code:
....AAAAAAAAA123  5...
....AAAAAAAAA300  5...


Here I need records with key which occur in 5 times.
Is this okay?
Back to top
View user's profile Send private message
Manuneedhi K

Active User


Joined: 07 May 2008
Posts: 115
Location: Chennai

PostPosted: Thu May 22, 2008 6:51 pm
Reply with quote

Hi Gnanas,

I used this.

Code:

   SORT FIELDS=(1,12,CH,A)                             
    OUTFIL REMOVECC,NODETAIL,                         
         SECTIONS=(1,12,                               
             TRAILER3=(1,12,X,COUNT=(M11,LENGTH=8)))   
 /*                                                   
 //S2    EXEC  PGM=SORT                               
 //SYSOUT    DD  SYSOUT=*                             
 //SORTMSG   DD  SYSOUT=*                             
 //SORTIN DD DSN=IFM4757.SORTTEMP,DISP=SHR             
 //SORTOUT DD DSN=IFM4757.SORTOUT,DISP=SHR             
 //SYSIN   DD    *                                     
   SORT FIELDS=(1,12,CH,A)                             
   INCLUDE COND=(14,8,CH,GE,C'00000005')               
 /*                                                   


Output was:
Code:

AAAAAAAAA123 00000005   
AAAAAAAAA300 00000005   



Can you check and confirm if this meets your requirement.
Back to top
View user's profile Send private message
Gnanas N

Active Member


Joined: 06 Sep 2007
Posts: 792
Location: Chennai, India

PostPosted: Thu May 22, 2008 6:56 pm
Reply with quote

Hi Manuneedhi,

Well, can you please let me know why you are sorting in second step also?

Is it possible in one step (instead of two steps)?
Back to top
View user's profile Send private message
Manuneedhi K

Active User


Joined: 07 May 2008
Posts: 115
Location: Chennai

PostPosted: Thu May 22, 2008 7:03 pm
Reply with quote

You could just use OPTION COPY there in the second step, sorting is not required.

Tried doing this in single step but couldn't see it working. I will probably check if it can be done that way.
Back to top
View user's profile Send private message
sril.krishy

Active User


Joined: 30 Jul 2005
Posts: 183
Location: hyderabad

PostPosted: Thu May 22, 2008 7:05 pm
Reply with quote

Please check the below code.

Code:

//IN1      DD  *                                   
....AAAAAAAAA123...                               
....AAAAAAAAA123...                               
....AAAAAAAAA123...                               
....AAAAAAAAA124...                               
....AAAAAAAAA123...                               
....AAAAAAAAA123...                               
....AAAAAAAAA125...                               
....AAAAAAAAA125...                               
....AAAAAAAAA300...                               
....AAAAAAAAA300...                               
....AAAAAAAAA300...                               
....AAAAAAAAA300...                               
....AAAAAAAAA300...                               
....AAAAAAAAA500...                               
....AAAAAAAAA999...                               
//OUT1     DD  DSN=xxxx.xxxx.xxxxx.REP1,           
//             DISP=(,CATLG,DELETE),               
//             UNIT=Sysdk,                         
//             SPACE=(TRK,(25,25),RLSE),           
//             DCB=(RECFM=FB,LRECL=80,BLKSIZE=800)
//OUT2     DD  DSN=xxxx.xxxx.xxxxx.REP2,           
//             DISP=(,CATLG,DELETE),               
//             UNIT=Sysdk,                         
//             SPACE=(TRK,(25,25),RLSE),           
//             DCB=(RECFM=FB,LRECL=80,BLKSIZE=800)
//TOOLIN   DD  *                                   
   SORT FROM(IN1) TO(OUT1) USING(CTL1)             
   SORT FROM(OUT1) TO(OUT2) USING(CTL2)           
//CTL1CNTL DD  *                                   
   INREC FIELDS=(5,12,C'00000001')                 
   SORT FIELDS=(1,12,CH,A)                         
   SUM FIELDS=(13,8,ZD)                           
   OUTREC FIELDS=(1,12,13,8,ZD,M10,80:X)           
//CTL2CNTL DD  *                                   
   SORT FIELDS=COPY                               
   INCLUDE COND=(20,1,CH,EQ,C'5')                 
/*                                                 

Thanks
Krishy
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 -> JCL & VSAM

 


Similar Topics
Topic Forum Replies
No new posts Compare 2 files and retrive records f... DFSORT/ICETOOL 3
No new posts Compare 2 files(F1 & F2) and writ... JCL & VSAM 8
No new posts Compare only first records of the fil... SYNCSORT 7
No new posts Pulling a fixed number of records fro... DB2 2
No new posts Substring number between 2 characters... DFSORT/ICETOOL 2
Search our Forums:

Back to Top