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

Use WHEN=GROUP for simple report


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
rmd3003

New User


Joined: 03 Jul 2006
Posts: 55

PostPosted: Wed Jul 14, 2010 6:18 am
Reply with quote

I have input file like this

Code:

ABC    001    1
ABC    099    1
ABC    050    1
XYZ    010    5
XYZ    010    5
XYZ    010    5
XYZ    010    5


I need to group by first three bytes and summarize. At the end I also need trailer with totals. Output should look like this

Code:
NAME   AMT    CNT
-----------------
ABC    150    3 
XYZ    040    20
-----------------
TOTAL  190    23


Thank you.
Back to top
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2481
Location: @my desk

PostPosted: Wed Jul 14, 2010 3:28 pm
Reply with quote

I guess you can achieve this using SECTIONS,TRAILER3 (section trailers)and a TRAILER1(report trailer) without really going for a WHEN=GROUP
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Wed Jul 14, 2010 10:11 pm
Reply with quote

rmd3003,

The following DFSORT JCL will give you the desired results

Code:

//STEP0100 EXEC PGM=SORT                       
//SYSOUT   DD SYSOUT=*                         
//SORTIN   DD *                                 
ABC    001    1                                 
ABC    099    1                                 
ABC    050    1                                 
XYZ    010    5                                 
XYZ    010    5                                 
XYZ    010    5                                 
XYZ    010    5                                 
//SORTOUT  DD SYSOUT=*                         
//SYSIN    DD *                                 
  SORT FIELDS=COPY                             
  OUTFIL REMOVECC,NODETAIL,                     
  HEADER1=('NAME   AMT    CNT',/,               
           '-----------------'),               
  SECTIONS=(1,3,                               
  TRAILER3=(1,3,2X,                             
            TOT=(8,3,ZD,M10,LENGTH=5),2X,       
            TOT=(15,1,ZD,M10,LENGTH=5))),       
  TRAILER1=('-----------------',/,             
            'TOTAL',                           
            TOT=(8,3,ZD,M10,LENGTH=5),2X,       
            TOT=(15,1,ZD,M10,LENGTH=5))         
//*


If you're not familiar with DFSORT and DFSORT's ICETOOL, I'd suggest reading through "z/OS DFSORT: Getting Started". It's an excellent tutorial, with lots of examples, that will show you how to use DFSORT, DFSORT's ICETOOL and DFSORT Symbols. You can access it online, along with all of the other DFSORT books, from:

Use [URL] BBCode for External Links
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 -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts Need help on formatting a report DFSORT/ICETOOL 14
No new posts Creating Report using SORT DFSORT/ICETOOL 7
No new posts Compare latest 2 rows of a table usin... DB2 1
No new posts Ca7 long running jobs report All Other Mainframe Topics 1
No new posts Report of batch jobs JCL & VSAM 1
Search our Forums:

Back to Top