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
 

 

Count number of Lines in a file

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> CLIST & REXX
View previous topic :: :: View next topic  
Author Message
hsk

New User


Joined: 28 Nov 2006
Posts: 69
Location: India

PostPosted: Thu Dec 11, 2008 3:08 pm    Post subject: Count number of Lines in a file
Reply with quote

Two questions ..........


1. Want to count number of lines in a file

- Function LINES ... not working (Error Routine not Found)
- How about EXECIO read into STEM) INDATA. ......
INDATA.0 will give me number of lines ... but generally files are large
Is there a better way ??

2. Want to execute this rexx (say CNTLN) from DSLIST.
3.4 displayes the list of datasets. I want user to write CNTLN infront of the file, this rexx shud count lines in file selected by user.
How to achieve this?
Back to top
View user's profile Send private message

enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10276
Location: italy

PostPosted: Thu Dec 11, 2008 3:18 pm    Post subject: Reply to: Count number of Lines in a file
Reply with quote

sort would be a better solution,
the task is just donkey work for the I/O, and REXX is not the best option
Back to top
View user's profile Send private message
hsk

New User


Joined: 28 Nov 2006
Posts: 69
Location: India

PostPosted: Thu Dec 11, 2008 4:16 pm    Post subject: Reply to: Count number of Lines in a file
Reply with quote

Found some solution ....
It's working for me, not sure if it's efficient or not !!!

Code:

/*REXX*/                                                               
ARG ds                                                                 
CALL MSG "OFF"                                                         
PARSE VALUE ? WITH sysreason re                                         
RC = LISTDSI(ds)                                                       
IF( sysreason<>? )THEN re = "REASON="sysreason                         
IF( RC>4 )THEN CALL ABEXIT RC,"LISTDSI ENDED WITH RC="RC re             
IF( sysdsorg<>"VS" )THEN CALL ABEXIT RC,sysdsorg "IS NOT SUPPORTED"     
"DELETE COUNT.TEMPFILE"                                                 
"ALLOC DD(COUNT) DS(COUNT.TEMPFILE) NEW REUSE UNIT(VIO) SP(30)TR",     
      "LRECL(32760) RECFM(V B S)"                                       
CALL MSG "ON"; CALL OUTTRAP "O."                                       
"PRINT IDS("ds") OFILE(COUNT) CHAR"                                     
pc = RC                                                                 
CALL OUTTRAP "OFF"; CALL MSG "OFF"                                     
"FREE DD(COUNT)"                                                       
"DELETE COUNT.TEMPFILE"                                                 
nr = WORD(o.1,WORDS(o.1))                                               
PARSE VALUE "NONE;YES;"nr "Records;Dataset" ds "contains" nr "records.",
      WITH  zerrhm";"zerralrm";"zerrsm";"zerrlm";"                     
ADDRESS ISPEXEC "SETMSG MSG(ISRZ002)"                                   
EXIT pc                                                                 
ABEXIT:                                                                 
PARSE ARG cc,ms                                                         
SAY ms                                                                 
ABEXIT:       
PARSE ARG cc,ms
SAY ms         
EXIT cc       
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10276
Location: italy

PostPosted: Thu Dec 11, 2008 4:39 pm    Post subject: Reply to: Count number of Lines in a file
Reply with quote

check
http://ibmmainframes.com/viewtopic.php?t=2235&highlight=dataset+record+count+sort

for faster ways of doing it using ICETOOL or DFSORT
Back to top
View user's profile Send private message
hsk

New User


Joined: 28 Nov 2006
Posts: 69
Location: India

PostPosted: Thu Dec 11, 2008 4:56 pm    Post subject: Reply to: Count number of Lines in a file
Reply with quote

gr8 !!!

Thanks !!!

I guess for smaller files, the rexx should not be a problem !!!
Actually want to make it quick, it would be good if i am getting count just by typing a command, rather than changing and submitting JCL then going to spool to check the SYSOUT.

For bigger files (like VSAM Master files), sort could be better option !!
Back to top
View user's profile Send private message
Pedro

Senior Member


Joined: 01 Sep 2006
Posts: 2058
Location: Silicon Valley

PostPosted: Thu Dec 11, 2008 11:00 pm    Post subject: Reply to: Count number of Lines in a file
Reply with quote

> (like VSAM Master files), sort could be better option

Can VSAM files really be sorted???
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Fri Dec 12, 2008 12:05 am    Post subject:
Reply with quote

Hi Pedro,

Quote:
Can VSAM files really be sorted???
Yes. Both DFSORT and Syncsort support vsam.
Back to top
View user's profile Send private message
Anuj Dhawan

Senior Member


Joined: 22 Apr 2006
Posts: 6258
Location: Mumbai, India

PostPosted: Fri Dec 12, 2008 10:32 am    Post subject:
Reply with quote

Hi Pedro,

You might like to check this link..
Back to top
View user's profile Send private message
Anuj Dhawan

Senior Member


Joined: 22 Apr 2006
Posts: 6258
Location: Mumbai, India

PostPosted: Fri Dec 12, 2008 10:32 am    Post subject:
Reply with quote

Hi again,

For some special considerations when using VSAM files, see:

http://publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/ICE1CA20/1.8.3.4?SHELF=&DT=20060615185603&CASE=
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 -> CLIST & REXX All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Extra character appears in file when ... Balu5491 All Other Mainframe Topics 1 Wed Jul 26, 2017 2:39 pm
No new posts SSH - known_hosts file configuration vasanthz All Other Mainframe Topics 2 Wed Jul 26, 2017 2:10 am
This topic is locked: you cannot edit posts or make replies. Fetching data from BAI File arunsoods JCL & VSAM 1 Wed Jul 19, 2017 4:28 pm
No new posts Write out NODUPS but just from one file Jay Villaverde DFSORT/ICETOOL 8 Fri Jul 14, 2017 12:44 am
No new posts How to add header with Date(YYMMDD) i... Rajan Moorthy DFSORT/ICETOOL 2 Thu Jul 06, 2017 11:44 pm


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