[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 OUTTRAP function

Execute a TSO command, and capture and use the output in your REXX program

This illustrates the use of the REXX OUTTRAP function.
/*REXX capture*/
/* Executes a TSO Command and captures the (normally) displayed
   output in a file named 'userid.CAPTURE.CMD.TEMP'
   To Use:
   Execute the program, 
      for example: %Capture
               or: TSO EXEC 'yourid.name-of-file-containing-this'
   Then type in a TSO command that displays output,
      for example: LISTCAT LEVEL(yourid)
                   STOP, QUIT, or just hitting ENTER will terminate at once 
   Then examine the file 'userid.CAPTURE.CMD.TEMP' to see what the command did

  for REXX information, sample code, books see:
                    http://theamericanprogrammer.com/
*/
ARG COMMAND DATASET_NAME
SIGNAL ON ERROR
IF DATASET_NAME = ""
THEN DATASET_NAME = "CAPTURE.CMD.TEMP"
IF SYSDSN(DATASET_NAME) = "OK"
THEN "ALLOCATE DSN(" DATASET_NAME ") DDN(CAPTURE) SHR REUSE"
ELSE "ALLOCATE DSN(" DATASET_NAME ") DDN(CAPTURE) NEW REUSE",
     " SPACE(1 1) TRACKS RELEASE"
DUMMY = OUTTRAP("LINE.","*")
IF COMMAND = ""
THEN
   DO
     SAY "PLEASE ENTER A COMMAND TO BE EXECUTED"
     PULL COMMAND
     IF COMMAND = "" THEN EXIT
     IF COMMAND = "QUIT" THEN EXIT
     IF COMMAND = "STOP" THEN EXIT
   END
COMMAND
DUMMY = OUTTRAP("OFF")
"EXECIO " LINE.0 " DISKW CAPTURE (STEM LINE. FINIS)"
"FREE DDN(CAPTURE)"
EXIT
ERROR:
SAY "COMMAND " COMMAND " CANNOT BE EXECUTED SUCCESSFULLY"
SAY "PRESS ENTER TO CONTINUE "
PULL .
"DELETE " DATASET_NAME
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 |