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
 

 

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

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> CLIST & REXX
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    Post subject: REXX command to get the total number of records in a file
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

Global Moderator


Joined: 14 Mar 2007
Posts: 10201
Location: italy

PostPosted: Thu Jul 30, 2009 9:35 pm    Post subject: Reply to: Getting count
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: 1288
Location: Chennai, India

PostPosted: Mon Aug 03, 2009 12:07 pm    Post subject: Reply to: REXX command to get the total number of records in
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

Active Member


Joined: 07 Feb 2009
Posts: 982
Location: Oostende, Belgium

PostPosted: Mon Aug 03, 2009 12:19 pm    Post subject: Re: Reply to: REXX command to get the total number of record
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: 1288
Location: Chennai, India

PostPosted: Mon Aug 03, 2009 1:56 pm    Post subject: Reply to: REXX command to get the total number of records in
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

Active Member


Joined: 07 Feb 2009
Posts: 982
Location: Oostende, Belgium

PostPosted: Mon Aug 03, 2009 3:59 pm    Post subject: Re: Reply to: REXX command to get the total number of record
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: 8593
Location: Back in jolly old England

PostPosted: Mon Aug 03, 2009 4:01 pm    Post subject:
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

Site Director


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

PostPosted: Mon Aug 03, 2009 7:56 pm    Post subject:
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: 401
Location: Mumbai

PostPosted: Mon Aug 03, 2009 11:46 pm    Post subject: Reply to: REXX command to get the total number of records in
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

Site Director


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

PostPosted: Tue Aug 04, 2009 12:16 am    Post subject:
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: 2158
Location: @my desk

PostPosted: Tue Aug 04, 2009 4:50 am    Post subject:
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

Senior Member


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

PostPosted: Tue Aug 04, 2009 6:43 am    Post subject: Reply to: REXX command to get the total number of records in
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: 401
Location: Mumbai

PostPosted: Tue Aug 04, 2009 7:26 am    Post subject:
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: 8593
Location: Back in jolly old England

PostPosted: Tue Aug 04, 2009 11:26 am    Post subject:
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: 401
Location: Mumbai

PostPosted: Tue Aug 04, 2009 12:16 pm    Post subject: Reply to: REXX command to get the total number of records in
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    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 Add PD field from 2nd file to PD in 1st Sushant Garje DFSORT/ICETOOL 6 Thu Dec 01, 2016 4:32 pm
No new posts File Aid to File Manager conversion murali3955 IBM Tools 4 Thu Nov 24, 2016 3:41 pm
No new posts Limit duplicate records in the SORT pshongal SYNCSORT 6 Mon Nov 21, 2016 12:54 pm
No new posts What is the command to check MODE of ... rohanthengal CLIST & REXX 6 Fri Nov 18, 2016 1:48 pm
No new posts How to convert the VBM file to VB or... Sulabh Agrawal JCL & VSAM 4 Fri Nov 18, 2016 1:04 pm


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