After completing this chapter, you will be able to:
Describe the overview of TSO/E Commands
Execute the common TSO commands
Write the miscellaneous TSO commands
Execute ISPF commands
Execute Rexx programs
TSO/E commands overview
In addition to the built-in functions, REXX supports the execution of external TSO commands. Some of these functions perform the same services as control variables do in CLIST language.
REXX can interact with the external TSO environment through TSO/E commands.
REXX can interact with external ISPF environment through ISPF commands.
TSO/E commands return the result in specific system variables through which REXX can access the attributes and track the status of datasets, user, and terminal and console session.
REXX can be used to perform basic TSO commands. Any TSO command can be performed in REXX by enclosing it within the double quotes prefixed by the word TSO.
Copy: "TSO COPY {source dataset} {destination dataset}"
Rename: "TSO RENAME {source dataset name} {destination dataset name}"
Delete: "TSO DELETE {dataset name}"
List Members: "TSO LISTDS {PDS dataset name} MEMBERS"
ADDRESS command will transfer the control to the respective external environment. For example, ADDRESS TSO will transfer the control to TSO environment.
Once ADDRESS TSO command is issued in a REXX program, all other commands enclosed in quotes will be considered as TSO commands.
ADDRESS TSO “COPY {source dataset} {destination dataset}” and “TSO COPY {source dataset} {destination dataset}” |
will result in the same outcome.
/* REXX */ /* Performing some basic TSO commands on PS file */ SRCFILE = {HLQ}.SAMPLE.FILE DESTFILE = {HLQ}.SAMPLE.FILE1 ADDRESS TSO "COPY '"SRCFILE"' '"DESTFILE"'" EXIT 0 |
Some of the miscellaneous TSO commands in REXX are as follows:
GETMSG
LISTDSI
MSG
MVSVAR
OUTTRAP
PROMPT
SETLANG
STORAGE
SYSCPUS
SYSDSN
SYSVAR
Returns in variables a system message issued during an extended MCS console session. It also returns associated information about the message in variables. The function call is replaced by a function code that indicates whether or not the call was successful.
Returns in variables the data set attributes of a specified data set. The function call is replaced by a function code that indicates whether or not the call was successful.
Controls the display of TSO/E messages. The function returns the previous setting of MSG.
Uses specific argument values to return information about MVS, TSO/E, and the current session.
Traps lines of TSO/E command output into a specified series of variables. When any TSO command is executed from REXX, the output can be stored in a stem variable using OUTTRAP command.
Let us say, {HLQ}.SAMPLE.DATA contains two members MEM1 & MEM2.
The TSO command LISTDS "{HLQ}.SAMPLE.DATA" MEMBERS will result in the following output.
{HLQ}.SAMPLE.DATA --RECFM-LRECL-BLKSIZE-DSORG FB 80 32720 PO --VOLUMES-- SLGMD0 --MEMBERS-- MEM1 MEM2 |
The above output can be stored in a stem variable TRAP. as follows,
ADDRESS TSO X=OUTTRAP(TRAP.) "LISTDS '{HLQ}.SAMPLE.DATA' MEMBERS" |
Sets the prompt option on or off for TSO/E interactive commands. The function returns the previous setting of prompt.
Retrieves and optionally changes the language in which REXX messages are displayed. The function returns the previous language setting
Retrieves and optionally changes the value in a storage address.
Returns in a stem variable information about all CPUs that are online.
For example:
SYSDSN("'{HLQ}.SAMPLE.DATA'") results in 'OK' if the data set exists, otherwise results in 'DATASET NOT FOUND'
Uses specific argument values to return information about the user, terminal, language, exec, system, and console session.
REXX can be used to perform basic ISPF commands.
Any ISPF command can be performed in REXX by enclosing it within the double quotes prefixed by the word ISPEXEC.
View: "ISPEXEC VIEW {dataset name>”
Edit: "ISPEXEC EDIT {dataset name>"
Save: "ISPEXEC SAVE"
Close: "ISPEXEC END"
ADDRESS command will transfer the control to the respective external ISPF environment. For example, ADDRESS ISPEXEC will transfer the control to ISPF environment.
Once ADDRESS ISPEXEC command is issued in the REXX program, all other commands that are enclosed in double quotes will be considered as ISPF commands.
ADDRESS ISPEXEC "VIEW {dataset name}" and "ISPEXEC VIEW {dataset name}" |
will result in the same outcome.
/* REXX */ /* Performing some basic ISPF commands on PS file */ SRCFILE = {HLQ}.SAMPLE.FILE ADDRESS ISPEXEC "VIEW SRCFILE" EXIT 0 |
Any REXX program can be executed from TSO by issuing the command,
TSO EX REXXLIB(member) |
Where, REXXLIB: PDS in which the REXX program is stored as a member.
If the Partitioned dataset (where the REXX program resides) is externally allocated to SYSEXEC/SYSPROC, REXX can be executed without specifying the library name "TSO member".
Apart from in-built functions, REXX can invoke external TSO commands.
The results of TSO commands will be returned to system variables or can be trapped through REXX stem variables.
ISPF commands can be invoked from REXX.
Which TSO command is used to check the existence of a dataset?
If you have any doubts or queries related to this chapter, get them clarified from our Mainframe experts on ibmmainframer Community!