A Community of and for MVS Programmers

REXX Technical FAQ's


Q How do I Run My Rexx Exec.?
A For the TSO environment:

Make sure the Exec starts with the /* REXX */ comment.
TSO EXEC 'hlq.your.dsn(member)' runs Rexx in exactly the same way as it would a CLIST.
TSO EX yourlib(member) E uses a suffix of EXEC and the TSO profile prefix to form a full DSN of 'your_prefix.yourlib.EXEC(member)'
The SYSEXEC concatenation can be used to run execs using TSO execname. The SYSPROC concatenation will do just as well, but is really intended for CLISTS.
TSO %execname parameter_string allows you to pass a parameter string to the exec, note that this string is only a single argument, not multiple arguments as can be used when calling from within an exec. The '%' instructs TSO to not use loadlib concatenations when constructing the search path.
For running Rexx in batch:

Create a batch environment for the Exec to run in with PGM=IRXJCL, PGM=IKJEFT01 or PGM=IKJEFT1B
IRXJCL is a straight batch environment
IKJEFT01 and IKJEFT1B are the TSO in batch programs.
Put the Rexx exec libraries in the SYSEXEC DD concatenation.
Call your exec via the PARM='yourprog' or as input in the SYSTSIN DD
Q How do I allocate Exec libraries and other datasets to my TSO or ISPF session?
A ALTLIB ACTIVATE can be used to dynamically add an Exec or Clist library to the search path. I dont know whether these ATLIBs are stacked in the way LIBDEFs can be.
LIBDEF can be used to dynamically allocate other libraries, such as ISPF panel libries. Use the STACK option to avoid corrupting the environment for nested calls to applications. An example LIBDEF/ALTLIB is in an appendix.
Your allocations at logon are controlled by the JCL procedure used to initiate your TSO environment. This is called your TSO LOGON PROCEDURE, and it will be under the control of your systems programmer.
To override the LOGON proc and allocate your own SYSEXEC, ISPPLIB, etc concatenations, the TSO ISRDDN command can create a handy CLIST to use as your base. To generate the TSO ALLOC commands needed to replicate your current allocations, type the CLIST command on the command line. Edit and save the Clist created, and run it at logon (outside of ISPF) to allocate your own environment.
Q How do I find or access the current level of a GDG?
A Use Outtrap() on the output of TSO LISTCAT.
Q How do I access data in control blocks such as jobname?
A Use the Storage() function to extract the data from control blocks.

/* REXX Get taskname from TCB */
cvt = storage(10,4) /* FLCCVT-PSA data area */
tcbp = storage(d2x(c2d(cvt)),4) /* CVTTCBP */
tcb = storage(d2x(c2d(tcbp)+4),4)
tiot = storage(d2x(c2d(tcb)+12),4) /* TCBTIO */
say strip(storage(d2x(c2d(tiot)),8)) /* TIOCNJOB */
Q How can I access a calling execs variables?
A Rexx doesn't allow an exec to access the symbols used by another exec. A classic example of this is creating an exec to sort the contents of a stemmed symbol.

Some suggested methods are:

Use ISPF variable pools to pass values across execs
Pass all symbols as arguments and returned values (I.e. Use PARSE ARG args and RETURN value).
Create your own function in assembler to pass stems across. Refer to the IRXEXCOM macro interface in the IBM Rexx manuals.
Generate executable code as the returned string and use INTERPRET on it to make the variables available in the external program.
Use the stack, see NEWSTACK, DELSTACK, PUSH, PULL, QUEUE, etc, in the manual.
Q Where are the Standard Rexx I/O functions?
A Linein(), Lineout(), Stream() etc. have not been implemented in MVS/Rexx *as far as I am aware*. I/O can be done using the functionality of EXECIO.
A function package giving I/O functions for the OE environment only is available from IBM's OE ftpsite.
Q How do I replicate CLIST's WRITENR functionality?
A The Rexx say command places a carriage return and line feed at the end of each say command execution.
Some suggestions for creating a say command that behaves in the same way as CLIST's WRITENR are:

Use a CLIST call.

Use CHAROUT(). However this I/O function is not implemented in MVS/Rexx.
Q Why does Outtrap() not trap all output?
A The Outtrap() function does not trap output written directly to the screen by the TPUT macro, but only traps output from the PUTLINE macro. Use PUTLINE when writing assembler programs, and your program will be of more use in a Rexx environment.

TSO Session Manager can be used to trap and manage all output that is normally written to the screen.
Q EXECIO, why does it require 'Enter' more than once?
A When using "EXECIO * DISKW DDNAME", Rexx will continue pulling input from the stack and from terminal input (depending on the users TSO PROMPT() value) until it gets a null line. So a users will have to hit enter once to generate a null line.

Solutions are:

Queue a null line before writing data from the stack.
Use the Queued() built in function instead of '*'.
Only EXECIO the required number of lines from terminal input.
"EXECIO 1 DISKR DDNAME (FINIS)" will only read a single line from the stack or terminal input.
"EXECIO "queued()" DISKW DDNAME (FINIS)" will write the entire stack without requiring a null line to terminate output.
Q How do I List Datasets and PDS members?
A There are various methods for listing datasets and PDS members.

LISTDS - TSO dataset list command. Use the MEMBERS subcommand to get the members of a PDS.
LM utilities - ISPF library management utilities. Use LMMLIST with LMINIT to list the members. See ISPF services manual for details.
EXECIO of the PDS directory. A PDS directory can be allocated (LRECL=256) and read with EXECIO. This method does not work with PDSEs and cannot be guaranteed to work in the future.
Create your own access routines in assembler using the BPAM access method.
CSI - Catalog Search Interface. A high performance catalog search routine shipped by IBM. Use the LINKMVS environment to use it.
FDR - Dataset management tools. Innovations FDR package supplies a tool for reporting upon datasets (FDREPORT) that can be customised for use with Rexx under TSO.
Q How do I access data held on the JES spool?
A JES3 sites can extract data off of the JES3 spool using E-JES.
Q What do unusual return codes such as -3 and 0196 mean?
A Basically they are either decimalised abend codes or indicate a problem with the environment.

E.g. 0196 is decimal for hex 0C4, -3 indicates external environment not found.
Q How do I pass parms to my ISPF Edit macro.
A From command line calls use ISPEXEC "MACRO (parms)"

From ISPEXEC EDIT call use VPUT and VGET


Home | Help Boards | Contact Us | News | Top

2002, MVSFORUMS. All Rights Reserved.