You are currently on IBM Systems Media’s archival website. Click here to view our new website.

MAINFRAME > Tips & Techniques > Application Development

REXX Talks

REXX Proves Multilingual in Communicating With Environments


Programs written in the REXX language can communicate with a variety of “environments.” In REXX, the classic environment refers to the address space or sub-system from which the REXX program was invoked, or called. REXX programs can use the ADDRESS function to return a string describing the current executing environment. You can test this with a simple REXX program called from within the time-sharing option (TSO):

/* REXX */ 
ADDR =  ADDRESS() 
SAY 'The environment from which I was called is: 'ADDR 
EXIT 

Take the three lines of code, place it within a REXX library accessible to your Userid and give it the member name ADDR, then execute it as follows, with the output result as shown here:

EXEC 'yourUserid.REXX(ADDR)'

The environment from which I was called is: TSO

TSO is the environment within which most people first encounter the REXX language, and in some senses, TSO could be thought of as its default calling environment. However REXX programs may be executed from a variety of other environments, too; for instance, within a batch program:

//yourUseridX JOB (ACCT),YOUR.NAME, 
//*           other jobcard details
//STEP1       EXEC PGM=IRXJCL,REGION=4096K,PARM='ADDR' 
//SYSEXEC     DD DISP=SHR,DSN=yourUserid.REXX 
//SYSTSPRT    DD SYSOUT=* 

The last line in the job output will state:

The environment from which I was called is: MVS

It gets more complicated than this, though, because from within one calling environment, REXX can send commands or instructions to another. The CONSOLE environment is a good example of this. A REXX exec running under your TSO session can send commands to the z/OS operations console and review the output of these commands. Simply replace yourUserid with your TSO Userid in the sample below and execute it:

/* REXX */ 
ADDRESS TSO 
"CONSPROF SOLDISP(NO) SOLNUM(50)" 
"CONSOLE ACTIVATE" 
x = outtrap('trap.') 
ADDRESS CONSOLE 
"D A,L,USERID=yourUserid CART('JOBL0001')" 
                                                                
CC = GETMSG('MSGS.',SOL,JOBL0001,,50) 
if CC = 0 then do 
   count = 1 
   do while count <= MSGS.0 
       say MSGS.count 
       count = count + 1 
   end 
end 
else do
   say 'error retrieving message output, return code was: 'cc 
end 
"DEACTIVATE" 
exit 

This demonstrates the z/OS operator command DISPLAY, in the form of a D A,L,USERID=yourUserid—which will list all active address spaces owned by your Userid, including your current TSO session. The loop through the message output can, of course, be used to filter the output further for selective display purposes. If you insert our first code sample somewhere after the ADDRESS CONSOLE statement, the output will be:

The environment from which I was called is: CONSOLE

Michael Cairns works for IBM as a technical specialist in the Tivoli zSecure range of software. Michael can be reached at mike.cairns@au1.ibm.com.



Advertisement

Advertisement

2019 Solutions Edition

A Comprehensive Online Buyer's Guide to Solutions, Services and Education.

A Beginner's Guide to the REXX Programming Language on z/OS

Reading and Writing Files in the REXX programming language on z/OS.

MAINFRAME > TIPS & TECHNIQUES > APPLICATION DEVELOPMENT

Application Management is Important to the Entire Process

MAINFRAME > TIPS & TECHNIQUES > APPLICATION DEVELOPMENT

Application Testing: Giving Users What They Need

IBM Systems Magazine Subscribe Box Read Now Link Subscribe Now Link iPad App Google Play Store
Mainframe News Sign Up Today! Past News Letters