z/OS

z/OS

z/OS

IBM z/OS is a widely-used mainframe operating system designed for a stable, secure and highly available environment for running mission-critical applications.

 View Only

Sharing REXX Variables between REXX Modules under ISPF

By Lionel Dyck posted Sat July 04, 2020 10:25 AM

  
WHen developing ISPF applications using REXX one quickly discovers that there is no global variable pool for REXX. There are several solutions to this challenge:

  1. Have one very large REXX exec so that the need to share REXX variables is not required
  2. Use the ISPF variable pool with the disadvantage that REXX stem variables are not supported
  3. Use an Open Source tool called SHAREVAR
SHAREVAR can be found on GitHub at https://github.com/lbdyck/sharevar

To use SHAREVAR it must be installed in a library where the developer can find it. Then it must be copied into each of the REXX exec's that will be sharing variables. A recommendation is that it be placed at the end of each REXX exec so it is out of the way of the mainline code.

It will have a REXX label of SHAREVAR and is a REXX procedure that is called when needed.

The calling syntax is: 

rc = sharevar(action ispfvar list)

rc is the return code from the function
action is GET to retrieve the passed variables and recreate them
Put is to take the REXX variables, including stem variables, and share them
ispfvar is the ISPF variable where the variables (name and contents) will be stored for sharing
list is a list, enclosed within quotes, of all the REXX variables to be shared

Note that for stems to be shared the stem must be numeric with the stem.0 containing the number of stems with values.

Some examples:

rc = sharevar('put' 'myspfvar' 'userid var1 var2 stem1. stem2.')

rc = sharevar('get' 'myspfvar')

The 1st example 'puts' the REXX variables in the current REXX exec out for sharing. The ISPF variable that will be used if 'myspfvar' (the ISPF variable names must be 1 to 8 characters unlike REXX variables which can be must longer). The variables to be shared are userid, var1, var2, stem1, and stem2.

The package includes 3 sample REXX exec's that demonstrate the use of SHAREVAR:

TVX is the driver exec that calls TVX0 and TVX1. 
TVX0 will share a large number of variables and a stem.
TVX1 will get the variables and display them.

There is a limit on the size of the transport ISPF variable which is 32K. If the transport will exceed that size then call SHAREVAR additional times with different transport ISPF variables.

The process used is not rocket science. The transport ISPF variable is constructed with the REXX variable name followed by the value, then a hex 01 as a delimiter, and then the next variable name, value, etc.

Are there other solutions to this deficiency within the z/OS REXX environment?  Probably, but this one works and is generalized.

Feedback and suggestions are welcome.

Happy coding in REXX for ISPF.
0 comments
27 views

Permalink