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

REXX command to get the total number of records in a file


IBM Mainframe Forums -> CLIST & REXX
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
sudalaimani

New User


Joined: 08 Apr 2009
Posts: 2
Location: chennai, india

PostPosted: Thu Jul 30, 2009 9:30 pm
Reply with quote

What is the REXX command to get the total number of records in a
file. Please suggest..
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Thu Jul 30, 2009 9:35 pm
Reply with quote

rexx is not the most practical tool for such a task...
search the forums for a sort approach ( syncsort/dfsort )
Back to top
View user's profile Send private message
Aaru

Senior Member


Joined: 03 Jul 2007
Posts: 1287
Location: Chennai, India

PostPosted: Mon Aug 03, 2009 12:07 pm
Reply with quote

Sudalaimani,

Quote:
What is the REXX command to get the total number of records in a
file. Please suggest..


You can read the file into a stem variable say X and X.0 will have the count of the number of records.
Back to top
View user's profile Send private message
prino

Senior Member


Joined: 07 Feb 2009
Posts: 1306
Location: Vilnius, Lithuania

PostPosted: Mon Aug 03, 2009 12:19 pm
Reply with quote

Aaru wrote:
Quote:
What is the REXX command to get the total number of records in a
file. Please suggest..


You can read the file into a stem variable say X and X.0 will have the count of the number of records.


This is a stupid suggestion given that the OP has given no indication about the potential number of records in the file. Doing an EXECIO on a file with 10 records is not a problem, doing the same on a file with 1,000,000 records is insane!
Back to top
View user's profile Send private message
Aaru

Senior Member


Joined: 03 Jul 2007
Posts: 1287
Location: Chennai, India

PostPosted: Mon Aug 03, 2009 1:56 pm
Reply with quote

Prino,

Then

Quote:
What is the REXX command to get the total number of records in a
file


????
Back to top
View user's profile Send private message
prino

Senior Member


Joined: 07 Feb 2009
Posts: 1306
Location: Vilnius, Lithuania

PostPosted: Mon Aug 03, 2009 3:59 pm
Reply with quote

Your
Aaru wrote:
You can read the file into a stem variable say X and X.0 will have the count of the number of records.


implies using EXECIO, which is a very bad suggestion on a file of unknown size.
Back to top
View user's profile Send private message
expat

Global Moderator


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

PostPosted: Mon Aug 03, 2009 4:01 pm
Reply with quote

REXX isn't the best IO handler for large files. I would steer away from a solution using REXX.
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: Mon Aug 03, 2009 7:56 pm
Reply with quote

Hello,

File processing (of large or unknown size files) in rexx is another of the things that "can be done", but should not be done. . .
Quote:
REXX isn't the best IO handler for large files
Ah, the gift of understatement. . . icon_wink.gif
Back to top
View user's profile Send private message
MBabu

Active User


Joined: 03 Aug 2008
Posts: 400
Location: Mumbai

PostPosted: Mon Aug 03, 2009 11:46 pm
Reply with quote

Rexx doesn't have native I/O so it doesn't make any sense to say that Rexx is a bad choice for this.

EXECIO, which is an external call, might be a bad or good choice depending on many factors like record size, frequency of use, need for a quick solution, etc. But you can also use Rexx to call any number of other programs. For example, you can Call SORT from Rexx and have it do the count, then use EXECIO to read the listing. Easy to code, quick to run, perfectly adaquate, and... its Rexx (as much as usiing EXECIO is, anyway).

you could also call ISPF services like LMGET, or call IEBGENER to copy to DUMMY and read the listing, etc, etc.
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: Tue Aug 04, 2009 12:16 am
Reply with quote

Hello,

Opinions vary. . . icon_smile.gif
If it didn't make sense, i'd not have posted same.
Quote:
Rexx doesn't have native I/O so it doesn't make any sense to say that Rexx is a bad choice for this.
Precisely because it doesn't have any "native i/o", and the number of new rexx'ers that seem to get completely enamored about EXECIO (and that population is growing), i say for much of our audience, rexx is a bad choice to copy large (or unknown) volume files.

For people who do know how to invoke other better suited utilities, fine, but for the ones who only know execio, best not done this way.

These are the same folks who get the 100 record test running perfectly and then "go live" and have to deal with running out of memory, running out of cpu cycles, running "forever" and on and on. . .
Back to top
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2481
Location: @my desk

PostPosted: Tue Aug 04, 2009 4:50 am
Reply with quote

Quote:
For example, you can Call SORT from Rexx and have it do the count, then use EXECIO to read the listing
Why not execute the sort "directly"?
Back to top
View user's profile Send private message
Pedro

Global Moderator


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

PostPosted: Tue Aug 04, 2009 6:43 am
Reply with quote

Quote:
Why not execute the sort "directly"?

Not sure what you mean by "directly", but a key point of this thread is that rexx is not particular good at I/O and it becomes more obvious for a large number of records.

My suggestion is to use LISTDSI to determine the number of blocks and cylinders and such. If it is small enough you can read the records. If it is too large, just compute an estimate by using the number of cylinders, the size of the blocks, and the lrecl to guess how many records there might be.
Back to top
View user's profile Send private message
MBabu

Active User


Joined: 03 Aug 2008
Posts: 400
Location: Mumbai

PostPosted: Tue Aug 04, 2009 7:26 am
Reply with quote

arcvns wrote:
Why not execute the sort "directly"?

Because getting the result is then a manual effort of reading the listing. Since the question is about Rexx, I assume that the intent is to use the number for some other automated purpose.

Pedro, just to belabor the point, you are talking about EXECIO which is one way to do I/O in rexx. It is not efficient for large numbers of records. But there are other ways to do I/O including calling other programs like sort, ispf, iebgener, some non-ibm function packages, homegrown function packages, and even CLISTs which can sometimes outperform Rexx for specific purposes. Rexx itself isn't terribly fast (at least on z/OS - Object Rexx on a PC is very fast) and neither is EXECIO, but it isn't fair to say that Rexx is bad at I/O. The Rexx language doesn't do file I/O -- external programs like EXECIO do it and some are better for certain tasks than others. Of course, the original question is a special case because all that is being done is counting so the interpreter never needs to see the contents of the records.
Back to top
View user's profile Send private message
expat

Global Moderator


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

PostPosted: Tue Aug 04, 2009 11:26 am
Reply with quote

Quote:
Because getting the result is then a manual effort of reading the listing. Since the question is about Rexx, I assume that the intent is to use the number for some other automated purpose.

Why not store and parse the output from the SYSOUT DDname ?
Back to top
View user's profile Send private message
MBabu

Active User


Joined: 03 Aug 2008
Posts: 400
Location: Mumbai

PostPosted: Tue Aug 04, 2009 12:16 pm
Reply with quote

That's exactly what I was suggesting. Using a utility like sort or IEBGENER, the output is going to come from somewhere in a file (listing or formatted output), and you can use EXECIO to read just that small file.
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 FTP VB File from Mainframe retaining ... JCL & VSAM 1
No new posts Compile Several JCL JOB Through one r... CLIST & REXX 4
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 RACF - Rebuild SETROPTS command which... All Other Mainframe Topics 3
Search our Forums:

Back to Top