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

JCL to return the count based on a key in a file


IBM Mainframe Forums -> JCL & VSAM
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Rahul Reddy R

New User


Joined: 01 Apr 2008
Posts: 4
Location: Mysore

PostPosted: Fri May 15, 2009 3:20 pm
Reply with quote

I need a JCL/Utility which returns the count for each key in a flat file.

Eg:
If the file has dept, vend and clr as fields and the data goes like this...

dept vend clr
220 336 100
220 336 120
220 336 250
220 450 500
220 450 850
360 254 120
360 254 560
360 254 720
360 265 560

The output should be the count based on dept and vend. i.e., as given below

dept vend count
220 336 3
220 450 2
360 254 3
360 265 1


Is there any way to get this result through a JCL/Utility instead of a program.

Thanks in Advance....
Rahul
Back to top
View user's profile Send private message
Escapa

Senior Member


Joined: 16 Feb 2007
Posts: 1399
Location: IL, USA

PostPosted: Fri May 15, 2009 3:36 pm
Reply with quote

How about using sort utility for it.. (Assuming input LRECL=11)
Code:

//S1    EXEC  PGM=SORT             
//SORTIN DD *                     
220 336 100                       
220 336 120                       
220 336 250                       
220 450 500                       
220 450 850                       
360 254 120                       
360 254 560                       
360 254 720                       
360 265 560                       
//SORTOUT   DD SYSOUT=*           
//SYSOUT    DD  SYSOUT=*           
//SYSPRINT DD SYSOUT=*             
//SYSIN    DD  *                   
  SORT FIELDS=(1,3,CH,A,5,3,CH,A) 
  SUM FIELDS=(12,8,ZD)             
  INREC BUILD=(1,11,C'00000001')   
  OUTREC BUILD=(1,8,12,8)     
/*                           

Output will be
Code:

220 336 00000003
220 450 00000002
360 254 00000003
360 265 00000001
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8797
Location: Welsh Wales

PostPosted: Fri May 15, 2009 3:36 pm
Reply with quote

Quote:
Is there any way to get this result through a JCL/Utility instead of a program.

[rant on]
What do really think that a JCL executes. It executes a program be it a utility or what.

All JCL does is to instruct the CPU which program to process, and which files are allocated to the process.
This process is called a job

[rant off]
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 -> JCL & VSAM

 


Similar Topics
Topic Forum Replies
No new posts Extract the file name from another fi... DFSORT/ICETOOL 6
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts To get the count of rows for every 1 ... DB2 3
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
Search our Forums:

Back to Top