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

Count Records in a file


IBM Mainframe Forums -> JCL & VSAM
Post new topic   This topic is locked: you cannot edit posts or make replies.
View previous topic :: View next topic  
Author Message
rahul_jot

New User


Joined: 17 Aug 2005
Posts: 22
Location: Pune

PostPosted: Fri Oct 23, 2009 3:49 pm
Reply with quote

Hi,

I want to count the number of records in a file and write the count into new output file. As per the requirement, I can not use tools like SORT, ICETOOL, FILEAID. I could do it with cobol, but I am looking for more efficient way. Can anyone help?

Thanks
Back to top
View user's profile Send private message
expat

Global Moderator


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

PostPosted: Fri Oct 23, 2009 4:04 pm
Reply with quote

Well, ICETOOL would be the most efficient way of doing it. What is the restriction on using the most efficient way of doing something ? These stupid requirements/limitations really get my goat icon_evil.gif

And another question is why do you need to have to count records, surely the creating program should be able to tell you this information rfather than wasting resource by reading a file just to count the number of records.

I guess it looks as though you are stuck with wasting time writing a program to do less efficiently than an already existing product.

Must be a really innovative place to work where you are icon_rolleyes.gif

But just in case you can wing it - maybe show the boss just how simple it really could be, here's the ICETOOL code.
Code:

//ICETOOL  EXEC PGM=ICETOOL                               
//TOOLMSG  DD SYSOUT=*                                     
//DFSMSG   DD SYSOUT=*                                     
//IN1      DD DSN=Input Data Set,DISP=SHR               
//OUT      DD DSN=&&TEMP01,DISP=(,PASS),                   
//            SPACE=(TRK,(15,15),RLSE),RECFM=FB,LRECL=80   
//OUFILE   DD SYSOUT=*                                     
//TOOLIN   DD *                                           
  COPY FROM(IN1) TO(OUT) USING(CTL1)                       
//CTL1CNTL   DD *                                         
  OPTION COPY                                             
  OUTFIL FNAMES=OUFILE,REMOVECC,NODETAIL,TRAILER1=(COUNT) 
Back to top
View user's profile Send private message
gcicchet

Senior Member


Joined: 28 Jul 2006
Posts: 1702
Location: Australia

PostPosted: Fri Oct 23, 2009 4:19 pm
Reply with quote

Hi,

or even simpler
Code:
//STEP001  EXEC PGM=ICETOOL                         
//TOOLMSG  DD SYSOUT=*                             
//DFSMSG   DD SYSOUT=*                             
//IN       DD DSN=input-file                       
//CT       DD SYSOUT=*                             
//TOOLIN   DD *                                     
COUNT FROM(IN) WRITE(CT)                           
/*                                                 


Gerry
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Fri Oct 23, 2009 4:45 pm
Reply with quote

doesn't idcams have a count function?
Back to top
View user's profile Send private message
expat

Global Moderator


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

PostPosted: Fri Oct 23, 2009 4:59 pm
Reply with quote

It does, but that is used to limit the number of records processed.

I suppose you could REPRO out the file and parse the output to get a count that way, but not as efficient as sort.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Fri Oct 23, 2009 5:50 pm
Reply with quote

Expat,

I agree, Sort is probably the best solution.

But the TP/OP environment seems so backwards,
I was proposing an alternate (acceptable) solution.

But again, it seems that an important point is being missed:

WTF are they counting records anyway?
Back to top
View user's profile Send private message
Steve Davies

New User


Joined: 15 Oct 2009
Posts: 32
Location: UK

PostPosted: Fri Oct 23, 2009 7:56 pm
Reply with quote

For what it's worth - we use ICETOOL (in the way Gerry has posted). We have a product which is distributed on mainframe and UNIX platforms. To ensure a release is behaving as expected on both platforms we validate many things, and one of those things is the number of records in the output files. If the record counts match on both platforms then that's one box ticked. So to achieve this we use ICETOOL on the mainframe to count the records in files. That's why we do it.
Back to top
View user's profile Send private message
rahul_jot

New User


Joined: 17 Aug 2005
Posts: 22
Location: Pune

PostPosted: Sat Oct 24, 2009 10:01 am
Reply with quote

I appreciate all help from each one of you. I usually prefer SORT/ICETOOL over cobol to do the tasks. But as per the requirement I received, I can't use it. I don't know why the requirement is so. Anyway I will again try to go back and have the requirement changed to use ICETOOL.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   This topic is locked: you cannot edit posts or make replies. View Bookmarks
All times are GMT + 6 Hours
Forum Index -> JCL & VSAM

 


Similar Topics
Topic Forum Replies
No new posts How to split large record length file... DFSORT/ICETOOL 8
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
No new posts Access to non cataloged VSAM file JCL & VSAM 18
Search our Forums:

Back to Top