Count the number of records in a Dataset using REXX.
Moderator: mickeydusaor
Count the number of records in a Dataset using REXX.
Hi,
Where I worked previously, they used to have a line command named "count". If you go to ISPF 3.4, locate the dataset and adjacent to it if we issue COUNT, it'll show you the number of records in the dataset. Now I realize it was probably a REXX written there. How can we create a REXX which can Count the number of records in a Dataset?
Where I worked previously, they used to have a line command named "count". If you go to ISPF 3.4, locate the dataset and adjacent to it if we issue COUNT, it'll show you the number of records in the dataset. Now I realize it was probably a REXX written there. How can we create a REXX which can Count the number of records in a Dataset?
-
- Global Moderator
- Posts: 836
- Joined: Wed Sep 11, 2013 3:57 pm
Re: Count the number of records in a Dataset using REXX.
investigate the use of ICETOOOL and the COUNT command
cheers
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort
-
- Global Moderator
- Posts: 490
- Joined: Sun Aug 25, 2013 7:24 pm
Re: Count the number of records in a Dataset using REXX.
A panel to allow a count of the number of records on a dataset? What a waste of resources. You know that someone (likely) pays for resource-usage on the Mainframe?
If you want to find out the number of records, don't lose them. Maintain them on a trailer/stats record, and reconcile them each time the dataset is read sequentially in full. Produce counts of input vs output and reconciling items at the end, and abend if discrepancies come to light.
Shoot the author of the panel.
If you want to find out the number of records, don't lose them. Maintain them on a trailer/stats record, and reconcile them each time the dataset is read sequentially in full. Produce counts of input vs output and reconciling items at the end, and abend if discrepancies come to light.
Shoot the author of the panel.
Re: Count the number of records in a Dataset using REXX.
I did not make it clear. COUNT was a line command. Once the data-set name is located in ISPF 3.4, adjacent to COUNT will written and enter. That gave the number of records. No panel was called.
-
- Global Moderator
- Posts: 836
- Joined: Wed Sep 11, 2013 3:57 pm
Re: Count the number of records in a Dataset using REXX.
You are splitting hairsI did not make it clear. COUNT was a line command. Once the data-set name is located in ISPF 3.4, adjacent to COUNT will written and enter. That gave the number of records. No panel was called.
to write something to count records and count records outside an application program is just a waste of resources
if Your applications need record count auditing , proper trailer processing should be put in place.
cheers
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort
- Anuj Dhawan
- Founder
- Posts: 2812
- Joined: Sun Apr 21, 2013 7:40 pm
- Location: Mumbai, India
- Contact:
Re: Count the number of records in a Dataset using REXX.
I think I get what are you asking. Perhaps because one of clients I worked for back in 2005 had such a tool in place. But for large files the use of REXX to count the number of records is overkill. You should listen to Enrico's advice. Having said that, try this REXX snippet from an old reference:
Please note, this will work only from/in TSO and/or ISPF. If you issue it on a PDS, you'll get count for number of members in the PDS.
Code: Select all
/* REXX COUNT */
ARG DSN .
IF DSN = "" THEN SIGNAL EXIOS
SYSDSORG = ""
CALL LISTDSI DSN "DIRECTORY" "RECALL"
IF SYSDSORG = "PS" THEN DO
NAME_TO_COUNT = TRANSLATE(DSN," ","'")
NAME_TO_COUNT = SPACE(NAME_TO_COUNT,0)
"ALLOC DSN(*) DDN(SYSPRINT) REUSE"
"ALLOC DDN(INFILE) SHR REUSE DSN("DSN")"
"ALLOC DUMMY DDN(OUTFILE) REUSE BLKSIZE(32000)"
CALL OUTTRAP "SYSPRINT." , "*"
"REPRO INFILE(INFILE) OUTFILE(OUTFILE) "
CALL OUTTRAP "OFF"
DO I = 1 TO SYSPRINT.0
/*SAY SYSPRINT.I*/
PARSE VAR SYSPRINT.I "WAS" RECORD_COUNT
IF DATATYPE(RECORD_COUNT) = "NUM" THEN LEAVE
END I
IF DATATYPE(SYSLRECL) = "NUM" THEN DO
SAY "RECORD COUNT = " RECORD_COUNT
SAY "RECORD LENGTH = " SYSLRECL
SAY "BYTE COUNT = " SYSLRECL * RECORD_COUNT
END
"ALLOC DDN(SYSIN) DSN(*) REUSE"
"ALLOC DDN(SYSPRINT) DSN(*) REUSE"
"FREE DDN(INFILE OUTFILE )"
EXIT
END /* FOR PS */
IF SYSDSORG = "PO" THEN DO
SAY SYSMEMBERS "MEMBERS IN PDS"
EXIT
END
IF SYSDSORG = "VS" THEN DO
SAY "CANNOT COUNT RECORDS IN VSAM DATASET"
EXIT
END
EXIOS:
SAY "COUNT WILL COUNT RECORDS IN A SEQUENTIAL FILE"
SAY "OR MEMBERS IN A PDS"
SAY "ANYTHING ELSE, CAN'T DO"
SAY "REEXECUTE. PUT COUNT TO LEFT OF DSNAME ON ISPF 3.4 DSLIST"
EXIT
Thanks,
Anuj
Disclaimer: My comments on this website are my own and do not represent the opinions or suggestions of any other person or business entity, in any way.
Anuj
Disclaimer: My comments on this website are my own and do not represent the opinions or suggestions of any other person or business entity, in any way.
- Akatsukami
- Global Moderator
- Posts: 122
- Joined: Tue Oct 20, 2015 3:20 am
- Location: Bloomington, IL
- Contact:
Re: Count the number of records in a Dataset using REXX.
You can easily write an exec fulfilling this requirement by reading the data set and incrementing a counter each time a record is read, then SAYing that counter at the end. Performance may range from adequate to unacceptable depending on the size of the data set.
Note that what Mr. Collins and Dr. Sorichetti are telling you is that this is an inferior solution to having properly designed programs; you ought to be able to determine the record count by browsing the trailer. We recognize that your words may have no weight in the design phase, but we senpai are usually reluctant to provide Band-aids® for self-inflicted wounds.
Note that what Mr. Collins and Dr. Sorichetti are telling you is that this is an inferior solution to having properly designed programs; you ought to be able to determine the record count by browsing the trailer. We recognize that your words may have no weight in the design phase, but we senpai are usually reluctant to provide Band-aids® for self-inflicted wounds.
"I come to the conclusion that, men loving according to their own will and fearing according to that of the prince, a wise prince should establish himself on that which is in his own control and not in that of others." -- Niccolò Machiavelli
-
- Global Moderator
- Posts: 836
- Joined: Wed Sep 11, 2013 3:57 pm
Re: Count the number of records in a Dataset using REXX.
for the umpteenth time ...
using Rexx to read Huge amounts of records will usually result in abends and unreasonably long/large elapsed/cpu times. AMEN
we reply on our own time, free of charge and we share experience
we provide solutions according to out best judgement and best practices
if You want poor solutions based on poor requirements and poor analysis hire a paid consultant
who for the proper fee will give You the solutions You asked for
using Rexx to read Huge amounts of records will usually result in abends and unreasonably long/large elapsed/cpu times. AMEN
we reply on our own time, free of charge and we share experience
we provide solutions according to out best judgement and best practices
if You want poor solutions based on poor requirements and poor analysis hire a paid consultant
who for the proper fee will give You the solutions You asked for
cheers
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort
Re: Count the number of records in a Dataset using REXX.
Hi,
I agree that this will be a CPU intensive process for the large files. But for a test region it should be fine? Or there are some constraints in this region too?
I agree that this will be a CPU intensive process for the large files. But for a test region it should be fine? Or there are some constraints in this region too?
Re: Count the number of records in a Dataset using REXX.
Why should unneccessary CPU-intensive processing of large datasets (not files) in a test region be acceptable? You will hinder the use of other developers/testers and be wasting resources. And, yes, there should be large datasets in the test region for stress testing (amongst other things).
Regards
Nic
Nic
Re: Count the number of records in a Dataset using REXX.
I agreee to all of you but why such a small thing is such a big deal in mainframes? On windows I have never heard people stopping you from doing it?
Re: Count the number of records in a Dataset using REXX.
Because a mainframe is a shared system - you are one of maybe thousands of people using it at the same time - not to mention other tasks. A PC is a single user machine - you are only holding yourself up.I agreee to all of you but why such a small thing is such a big deal in mainframes? On windows I have never heard people stopping you from doing it?
Regards
Nic
Nic
Re: Count the number of records in a Dataset using REXX.
Why not try to be professional and run a test or two of your own?Will using ICETOOL helps compared to REXX?
Regards
Nic
Nic
-
- Global Moderator
- Posts: 588
- Joined: Wed Nov 20, 2013 11:53 am
- Location: Mars
Re: Count the number of records in a Dataset using REXX.
As Enrico said REXX is not powerful to handle huge amount of records,
Why not use OUTFIL + TRAILER + COUNT through DFSORT ?
Why not use OUTFIL + TRAILER + COUNT through DFSORT ?
zprogrammer
Re: Count the number of records in a Dataset using REXX.
I have tried the follwoing solutions but with 1000 records there is not much difference between CPU use. I shall use REXX as we do not have much records to cound for now. But it helps in small testing easilty.
With ICETOOL:
With REXX:
And Sort:
With ICETOOL:
Code: Select all
//STEPCNT EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN DD DSN=MY.INPUT.DATASET,
// DISP=SHR
//TOOLIN DD *
COUNT FROM(IN)
/*
Code: Select all
/* REXX COUNT */
ARG DSN .
IF DSN = "" THEN SIGNAL EXIOS
SYSDSORG = ""
CALL LISTDSI DSN "DIRECTORY" "RECALL"
IF SYSDSORG = "PS" THEN DO
NAME_TO_COUNT = TRANSLATE(DSN," ","'")
NAME_TO_COUNT = SPACE(NAME_TO_COUNT,0)
"ALLOC DSN(*) DDN(SYSPRINT) REUSE"
"ALLOC DDN(INFILE) SHR REUSE DSN("DSN")"
"ALLOC DUMMY DDN(OUTFILE) REUSE BLKSIZE(32000)"
CALL OUTTRAP "SYSPRINT." , "*"
"REPRO INFILE(INFILE) OUTFILE(OUTFILE) "
CALL OUTTRAP "OFF"
DO I = 1 TO SYSPRINT.0
/*SAY SYSPRINT.I*/
PARSE VAR SYSPRINT.I "WAS" RECORD_COUNT
IF DATATYPE(RECORD_COUNT) = "NUM" THEN LEAVE
END I
IF DATATYPE(SYSLRECL) = "NUM" THEN DO
SAY "RECORD COUNT = " RECORD_COUNT
SAY "RECORD LENGTH = " SYSLRECL
SAY "BYTE COUNT = " SYSLRECL * RECORD_COUNT
END
"ALLOC DDN(SYSIN) DSN(*) REUSE"
"ALLOC DDN(SYSPRINT) DSN(*) REUSE"
"FREE DDN(INFILE OUTFILE )"
EXIT
END /* FOR PS */
IF SYSDSORG = "PO" THEN DO
SAY SYSMEMBERS "MEMBERS IN PDS"
EXIT
END
IF SYSDSORG = "VS" THEN DO
SAY "CANNOT COUNT RECORDS IN VSAM DATASET"
EXIT
END
EXIOS:
SAY "COUNT WILL COUNT RECORDS IN A SEQUENTIAL FILE"
SAY "OR MEMBERS IN A PDS"
SAY "ANYTHING ELSE, CAN'T DO"
SAY "REEXECUTE. PUT COUNT TO LEFT OF DSNAME ON ISPF 3.4 DSLIST"
EXIT
Code: Select all
//STEPCNT EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=MY-INPUT-DATASET,
// DISP=SHR
//SORTOUT DD DUMMY
//SYSIN DD *
SORT FIELDS=COPY
/*
Create an account or sign in to join the discussion
You need to be a member in order to post a reply
Create an account
Not a member? register to join our community
Members can start their own topics & subscribe to topics
It’s free and only takes a minute