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
-
- Similar Topics
- Replies
- Views
- Last post
-
- 3
- 3721
-
by naveenkumar sudha
View the latest post
Mon May 09, 2022 10:15 pm
-
-
SUM and count of records by key, using SORT utility
by naveenkumar sudha » Mon May 09, 2022 10:11 pm » in DFSORT/ICETOOL/ICEGENER - 2
- 6543
-
by ssbylzh
View the latest post
Sat May 21, 2022 5:10 pm
-
-
-
SORT the records based on the second word
by seethahexa » Wed Aug 19, 2020 1:30 pm » in DFSORT/ICETOOL/ICEGENER - 1
- 1415
-
by sergeyken
View the latest post
Wed Aug 19, 2020 6:08 pm
-
-
-
Split file, SORT then append records.
by Esmayeelhusen » Fri Aug 04, 2023 6:37 pm » in DFSORT/ICETOOL/ICEGENER - 10
- 5432
-
by Esmayeelhusen
View the latest post
Wed Aug 09, 2023 7:39 am
-
-
- 14
- 8365
-
by indianrajput
View the latest post
Wed Nov 24, 2021 11:33 pm