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 !
Sort on number of records in block
- Frank Yaeger
- Global moderator
- Posts: 1079
- Joined: Sat Jun 09, 2007 8:44 pm
- Skillset: DFSORT, ICETOOL, ICEGENER
- Referer: Search
- Contact:
Re: Sort on number of records in block
You can use a DFSORT/ICETOOL job like the following to do what you asked for:
Code: Select all
//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
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
=> DFSORT/MVS is on the Web at http://www.ibm.com/storage/dfsort
-
- Posts: 2
- Joined: Fri Jan 04, 2008 8:33 pm
- Skillset: jcl, cobol, db2, cics, mvs, dl1
- Referer: google
Re: Sort on number of records in block
Thanks for your help, Frank !!
I adapted your coding to fit my jcl & sort-fields and it works perfectly
(Also, I downloaded your latest DFSORT-manuals -- apparently the version I had was a bit old ...)
I adapted your coding to fit my jcl & sort-fields and it works perfectly

(Also, I downloaded your latest DFSORT-manuals -- apparently the version I had was a bit old ...)
- Frank Yaeger
- Global moderator
- Posts: 1079
- Joined: Sat Jun 09, 2007 8:44 pm
- Skillset: DFSORT, ICETOOL, ICEGENER
- Referer: Search
- Contact:
Re: Sort on number of records in block
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
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
=> DFSORT/MVS is on the Web at http://www.ibm.com/storage/dfsort