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

SORT - Count of records (grouped by a field)


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
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
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
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
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
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: 2481
Location: @my desk

PostPosted: Thu Feb 26, 2009 4:02 pm
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
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
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
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts Compare 2 files and retrive records f... DFSORT/ICETOOL 3
No new posts Compare 2 files(F1 & F2) and writ... JCL & VSAM 8
No new posts Need to set RC4 through JCL SORT DFSORT/ICETOOL 5
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts To get the count of rows for every 1 ... DB2 3
Search our Forums:

Back to Top