Sort on number of records in block



JES, JES2, JCL utilities, IDCAMS, Compile & Run JCLs, PROCs etc...

Sort on number of records in block

Postby bastos » Fri Jan 04, 2008 9:03 pm

I have following sort-problem :
I perform a sort on a number of fields in a dataset, which gives me a number of 'blocks' with similar sort fields. Now I need to count the number of records in these blocks and use this number as a new sort criteria.

eg. after my inital sort I have following file (sorted on char 1 and 2)
AAxxxx
AAxxxx ---- AA has 2 records
ABxxxx ---- AB has 1 record
BAxxxx ---- BA has 1 record
BBxxxx
BBxxxx ---- BB has 2 records

now I need to resort with criteria (char1 / # of records (desc) /char2) which should result in
AAxxxx
AAxxxx
ABxxxx
BBxxxx
BBxxxx
BAxxxx

how do I count the records in my 'blocks' and use this as a sort-criterium ???
I read DFSORT and ICETOOLS manuals but found nothing to help me.
I could write a small program to add #records after initial sort but I'd prefer to do this in JCL ...

any help is greatly appreciated !
bastos
 
Posts: 2
Joined: Fri Jan 04, 2008 8:33 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Sort on number of records in block

 

Re: Sort on number of records in block

Postby Frank Yaeger » Fri Jan 04, 2008 10:58 pm

You can use a DFSORT/ICETOOL job like the following to do what you asked for:

//S1    EXEC  PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG  DD SYSOUT=*
//IN DD *
AA R01
AA R02
AB R03
BA R04
BB R05
BB R06
/*
//T1 DD DSN=&&T1,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(,PASS)
//T2 DD DSN=&&T2,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(,PASS)
//OUT DD SYSOUT=*
//TOOLIN DD *
SORT FROM(IN) USING(CTL1)
SPLICE FROM(T1) TO(T2) ON(1,2,CH) -
  WITHALL WITH(1,80) USING(CTL2)
SORT FROM(T2) TO(OUT) USING(CTL3)
/*
//CTL1CNTL DD *
  INREC OVERLAY=(89:C'1')
  OPTION EQUALS
  SORT FIELDS=(1,2,CH,A)
  OUTFIL FNAMES=T1,REMOVECC,SECTIONS=(1,2,
    TRAILER3=(1,2,81:COUNT=(M11,LENGTH=8),89:C'0'))
/*
//CTL2CNTL DD *
  SORT FIELDS=(1,2,CH,A,89,1,CH,A)
/*
//CTL3CNTL DD *
  SORT FIELDS=(1,1,CH,A,81,8,ZD,D,2,1,CH,A)
  OUTREC BUILD=(1,80)
/*
Frank Yaeger - DFSORT Development Team (IBM) - yaeger@us.ibm.com
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
=> DFSORT/MVS is on the Web at http://www.ibm.com/storage/dfsort
User avatar
Frank Yaeger
Global moderator
 
Posts: 1080
Joined: Sat Jun 09, 2007 8:44 pm
Has thanked: 0 time
Been thanked: 14 times

Re: Sort on number of records in block

Postby bastos » Wed Jan 09, 2008 2:57 pm

Thanks for your help, Frank !!
I adapted your coding to fit my jcl & sort-fields and it works perfectly :D

(Also, I downloaded your latest DFSORT-manuals -- apparently the version I had was a bit old ...)
bastos
 
Posts: 2
Joined: Fri Jan 04, 2008 8:33 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Sort on number of records in block

Postby Frank Yaeger » Wed Jan 09, 2008 10:23 pm

Glad I could help.
Frank Yaeger - DFSORT Development Team (IBM) - yaeger@us.ibm.com
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
=> DFSORT/MVS is on the Web at http://www.ibm.com/storage/dfsort
User avatar
Frank Yaeger
Global moderator
 
Posts: 1080
Joined: Sat Jun 09, 2007 8:44 pm
Has thanked: 0 time
Been thanked: 14 times


Return to JCL

 


  • Related topics
    Replies
    Views
    Last post