MVSFORUMS.com A Community of and for MVS Professionals
View previous topic :: View next topic
Author
Message
neoframer Beginner Joined: 28 Jun 2003 Posts: 10 Topics: 6
Posted: Wed Jan 28, 2004 6:32 pm Post subject: Totals in report
I have following inut file sorted on key (Column position 1:2)
01
01
02
02
02
03
04
04
04
07
09
09
11
My output should look like this: i.e. with total of each record in front of it:
01 2
02 3
03 1
04 3
07 1
09 2
11 1
EZT/Sort solution is desired.
Back to top
kolusu Site Admin Joined: 26 Nov 2002 Posts: 12370 Topics: 75 Location: San Jose
Posted: Wed Jan 28, 2004 7:07 pm Post subject:
Neoframer,
The following DFSORT JCl will give you the desired results.
Code:
//STEP0100 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
01
01
02
02
02
03
04
04
04
07
09
09
11
//SORTOUT DD DSN=YOUR OUTPUT DSN,
// DISP=(NEW,CATLG,DELETE),
// UNIT=SYSDA,
// SPACE=(CYL,(X,Y),RLSE)
//SYSIN DD *
INREC FIELDS=(1,2, $ FIRST 2 BYTES
C'00000001') $ A CONSTANT OF 1 FOR 8 BYTES
SORT FIELDS=(1,2,CH,A) $ SORT ON KEY
SUM FIELDS=(3,8,ZD) $ SUM ON THE CONSTANT
OUTREC FIELDS=(1,2, $ FIRST 2 BYTES
3,8,ZD,M10) $ EDIT MASK THE TOTAL FOR LEADING 0 SUPPRESSION
/*
Hope this helps...
Cheers
Kolusu _________________ Kolusu
www.linkedin.com/in/kolusu
Back to top
Frank Yaeger Sort Forum Moderator Joined: 02 Dec 2002 Posts: 1618 Topics: 31 Location: San Jose
Posted: Wed Jan 28, 2004 7:27 pm Post subject:
Here's another way to do it with DFSORT. This will produce an output file with the same LRECL as the input file.
Code:
//F1 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=... input file
//SORTOUT DD DSN=... output file
//SYSIN DD *
SORT FIELDS=(1,2,CH,A)
OUTFIL REMOVECC,NODETAIL,
SECTIONS=(1,2,
TRAILER3=(1,2,X,COUNT =(M10,LENGTH=5)))
/*
And here's a way to do it with DFSORT's ICETOOL. However, this will produce an output file with RECFM=FBA and LRECL=121 which you may or may not want:
Code:
//F2 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN DD DSN=... input file
//OUT DD SYSOUT=*
//TOOLIN DD *
OCCUR FROM(IN) LIST(OUT) ON(1,2,CH) ON(VALCNT,N05) -
NOHEADER
/*
_________________ Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Back to top
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