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

Count number of Lines in a file


IBM Mainframe Forums -> CLIST & REXX
Post new topic   Reply to topic
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
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

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Thu Dec 11, 2008 3:18 pm
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
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

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Thu Dec 11, 2008 4:39 pm
Reply with quote

check
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
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

Global Moderator


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

PostPosted: Thu Dec 11, 2008 11:00 pm
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

Moderator Emeritus


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

PostPosted: Fri Dec 12, 2008 12:05 am
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

Superior Member


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

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

Hi Pedro,

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

Superior Member


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

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

Hi again,

For some special considerations when using VSAM files, see:

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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> CLIST & REXX

 


Similar Topics
Topic Forum Replies
No new posts Compare 2 files and retrive records f... DFSORT/ICETOOL 3
No new posts FTP VB File from Mainframe retaining ... JCL & VSAM 8
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
Search our Forums:

Back to Top