[USflag] The American Programmer [USflag]


Home
Books on Mainframe Programming
Mainframe Manuals and Tutorials
System Abend codes, Sqlcodes, VSAM/QSAM codes
Everything about the IBM AS/400 Midrange Computer - iSeries
Everything about CICS
Everything about COBOL
Everything about DB2 and SQL
Everything about IMS
Everything about Java and JavaScript
Everything about JCL and JES
Everything about REXX
  Sorting in REXX: The Bubble Sort
  REXX Password Generator
  Using REXX to capture displayed output of TSO command
  Count records in REXX
  REXX program to calculate present value of money
  REXX function to format a number in currency format
  REXX function to produce a fixed-length number
  REXX program to produce lottery numbers
  REXX: what does your phone number spell?
  REXX Practice Problems.
  Just Enough REXX Tutorial
  Setting up to Execute REXX Programs on TSO/ISPF
  How to execute a REXX program
  REXX Boolean operators
  Comparison of CLIST language and REXX
  REXX Comparison operators
  REXX Debugging: the TRACE verb
  Using REXX OUTTRAP
  Reserved REXX Variables
  Executing REXX through JCL.
  Writing ISPF Edit Macros in REXX
  REXX program to unload a PDS
  REXX book: The REXX Language on TSO
  REXX Functions Book
  QMF Procedures Written in REXX
  Using REXX Subroutines with the QMF Calc panel
  REXX error codes (RC)
  REXX programming language manuals
  Books on REXX programming
  The REXX Files
Everything about zOS, VSAM, Tivoli, Assembler
Everything about TSO, ISPF, Spufi
Site Map and Site Search

           Home   > REXX   > REXX: Count records

REXX program to count records

This illustrates the use of the REXX LISTDSI function, SYSDSORG, and TSO command REPRO.
If dataset is a PDS, displays number of members.
/* REXX COUNT
   TSO and/or ISPF ONLY
   REXX command to count records if sequential,
       count members if a pds

   to use: 
   COUNT the-dataset-to-be-counted

   IF INPUT IS SEQUENTIAL, COUNTS RECORDS
   IF INPUT IS A PDS, COUNTS MEMBERS
   NO OTHER TYPES OF INPUT WILL WORK.

   FOR TSO/ISPF ONLY

  for REXX information, Sample Code, books see

                    http://theamericanprogrammer.com


*/

ARG DSN  .
IF DSN = "" THEN SIGNAL ADIOS

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

ADIOS:
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


Learn how to use all the features of REXX: REXX Programming Book for TSO (published 2012)

[Books Computer]

Home Books for Computer Professionals Privacy Terms |
Site Map and Site Search Programming Manuals and Tutorials The REXX Files Top of Page |