Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

SORT - Count of records (grouped by a field)

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
View previous topic :: :: View next topic  
Author Message
antonrino.b

New User


Joined: 10 Jan 2006
Posts: 76
Location: Germany

PostPosted: Mon Feb 23, 2009 10:49 pm    Post subject: SORT - Count of records (grouped by a field)
Reply with quote

Hi,

I need to group the records by a particular field, and get the no. of records per group.

For eg.

I have the input file with layout as below:

Code:
SER-NO     PIC 9(3).
FILLER     PIC X(1).
DEP-ID     PIC 9(3).
FILLER     PIC X(1).
SUB-DIV    PIC 9(3).

001 111 100
002 111 100
003 111 110
004 222 100
005 222 100
006 222 110


The output, i would like to have is

Code:
111 100 2   (no. of records with 111 100)
111 110 1   (no. of records with 111 110)
222 100 2
222 110 1


Is this possible with DFSORT?
Back to top
View user's profile Send private message

Skolusu

Senior Member


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

PostPosted: Mon Feb 23, 2009 10:55 pm    Post subject: Reply to: SORT - Count of records (grouped by a field)
Reply with quote

antonrino.b,

Use the following DFSORT JCL

Code:

//STEP0100 EXEC PGM=SORT                             
//SYSOUT   DD SYSOUT=*                               
//SORTIN   DD *                                       
001 111 100                                           
002 111 100                                           
003 111 110                                           
004 222 100                                           
005 222 100                                           
006 222 110                                           
//SORTOUT  DD SYSOUT=*                               
//SYSIN    DD *                                       
  SORT FIELDS=(5,7,CH,A)                             
  OUTFIL REMOVECC,NODETAIL,                           
  SECTIONS=(5,7,TRAILER3=(5,7,X,COUNT=(M10,LENGTH=3)))
/*
Back to top
View user's profile Send private message
antonrino.b

New User


Joined: 10 Jan 2006
Posts: 76
Location: Germany

PostPosted: Mon Feb 23, 2009 11:38 pm    Post subject:
Reply with quote

Hi kolusu,

Thanks for your instant reply. it worked fine. :-)
Back to top
View user's profile Send private message
Sachinrethin

New User


Joined: 12 Oct 2007
Posts: 21
Location: Chennai

PostPosted: Thu Feb 26, 2009 1:58 pm    Post subject: Re : SORT - Count of records (grouped by a field)
Reply with quote

Hi ,

I tried the below piece of control card and got the output.

Code:

  INREC OVERLAY=(81:C'1')       
  SORT FIELDS=(5,7,CH,A)       
  SUM FIELDS=(81,1,ZD)         
  OUTREC FIELDS=(5,7,X,81,1)
Back to top
View user's profile Send private message
Arun Raj

Moderator


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

PostPosted: Thu Feb 26, 2009 4:02 pm    Post subject:
Reply with quote

Sachinrethin,

This works, but I think it's not as efficient as Kolusu's since he does n't have an INREC pass.
Back to top
View user's profile Send private message
Skolusu

Senior Member


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

PostPosted: Thu Feb 26, 2009 9:38 pm    Post subject: Reply to: SORT - Count of records (grouped by a field)
Reply with quote

sachinretin,

what happens if you have more than 9 duplicates? you are just summing on 1 byte field. Run your job using this input and see if you got the results correctly. Run the same job using the control cards I provided and notice the difference.

Code:

001 111 100
001 111 100
001 111 100
001 111 100
001 111 100
001 111 100
001 111 100
001 111 100
001 111 100
001 111 100
002 111 100
003 111 110
004 222 100
005 222 100
006 222 110
Back to top
View user's profile Send private message
Sachinrethin

New User


Joined: 12 Oct 2007
Posts: 21
Location: Chennai

PostPosted: Fri Feb 27, 2009 3:38 pm    Post subject: Re:SORT - Count of records (grouped by a field)
Reply with quote

Hi,

I agree with your point. so it is always better to have the counter as 9 digits.
Back to top
View user's profile Send private message
Skolusu

Senior Member


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

PostPosted: Fri Feb 27, 2009 9:37 pm    Post subject:
Reply with quote

Sachinrethin,

Apart from the count being 9 bytes , you are doing an additional pass with INREC. For FB files it is ok but for variable block files adding a counter at the end of every record would be nullifying the whole variable block concept.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts How to change 'K' or 'M' use Sort vice_versa DFSORT/ICETOOL 5 Thu May 18, 2017 7:11 am
No new posts Check if any Detail records and extra... V S Amarendra Reddy SYNCSORT 19 Mon May 08, 2017 8:54 pm
No new posts Adding big TEXT lines to each record ... bshkris SYNCSORT 4 Sat May 06, 2017 1:40 am
This topic is locked: you cannot edit posts or make replies. Merge two files and update Trailer re... Yashashri JCL & VSAM 1 Thu May 04, 2017 12:54 pm
No new posts READ A PACKED "NEGATIVE" FI... jdesouza CA Products 3 Tue May 02, 2017 11:43 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us