IBM Z and LinuxONE - Languages - Group home

TSO REXX Productivity

  

TSO REXX Productivity

Examples of how to generate a list of partitioned data set member names and data set names for additional processing

By @Lionel Dyck & @Ray MullinsTrident Services, Inc.

The REXX Language

REXX was a boon to productivity when it was introduced first to the VM/SP 3 operating system in the early 1980s, then the MVS/XA operating system in the late 1980s, and then the VSE/ESA operating system in the mid-1990s. This programming language provided a simple-to-understand syntax with immense power to both prototype and fully develop those applications. The introduction of the REXX Compiler further enhanced the usefulness of the language.

This article contains three examples of using REXX for common tasks around data sets. One group of examples demonstrates different techniques to process a list of partitioned data set members and populate a REXX stem for later processing in the program. Techniques used are

  1.  the TSO LISTDS command;
  2.  ISPF Library Services;
  3. the TSO Pipelines LISTPDS command;
  4. the TSO Pipelines LISTISPF command.

The ISPF methods also provide ISPF statistics that can be used to further filter processing.

The next example group demonstrates reading data from a z/OS data set into a stem for processing. There are four examples: a pair that use TSO ALLOCATE/EXECIO/FREE and a pair that use TSO Pipelines. Each pair has an example of reading all records into a REXX stem variable, and the other example selects specific records for later processing.

The last example group demonstrates the generation of a list of data set names. There are two in this group: one uses the TSO LISTC command and REXX code to reduce the command-generated data to just the data set names. The second example uses the TSO Pipelines LISTCAT command.

Note regarding TSO Pipelines

TSO Pipelines is not part of the base z/OS product; however, it is available from IBM as part of the priced IBM Batchpipes for OS/390 Version 2 Release 1 (5655-D45) product. Click here for more information.

Member List Examples:

TSO LISTDS Command Technique

call outtrap 'list.'

 'listds' dsn 'mem'

 call outtrap 'off'

 count = 0

 do i = 7 to list.0   /* members start on record 7 */

   count = count + 1

   listdmem.count = word(list.i,1)

 end

 listdmem.0 = count

PIPE LISTPDS Technique

'pipe listpds' dsn '| chop blank | stem pipelpds.'

ISPF Library Services Technique

Address ISPEXEC

"LMINIT DATAID(STATUS) DATASET("dsn")"

"LMOPEN DATAID("STATUS") OPTION(INPUT)"

count = 0

member = ''

do forever

  "LMMLIST Dataid("status") OPTION(LIST) MEMBER(MEMBER)",

    "STATS(YES)"

  if rc = 4 then do

    say 'no members found matching pattern'

    exit

    end

if rc > 7 then leave

count = count + 1

ispfmem.count = member ,

  zlc4date zlm4date ZLVERS ZLMOD ZLMTIME ZLCNORC ,

  ZLINORC ZLMNORC ZLUSER ,

  'ext:' zlcnorce zlinorce zlmnorce

end

ispfmem.0 = count

"LMClose Dataid("status")"

"LMFree  Dataid("status")"

PIPE LISTISPF Technique

'pipe listispf' dsn '| stem pipemem.'

Read Entire File Examples

EXECIO

'alloc f('dd') shr ds('dsn') reuse'

'execio * diskr' dd '(finis stem eio.'

'free  f('dd')'

EXECIO Select

'alloc f('dd') shr ds('dsn') reuse'

'execio * diskr' dd '(finis stem eio.'

'free  f('dd')'

c = 0

do i = 1 to eio.0

  if pos(string,eio.i) > 0

  then do

    c = c + 1

    found.c = eio.i

  end

end

found.0 = c

PIPE

'pipe <' dsn '| stem pipeio.'

PIPE Select

'pipe <' dsn '| loc /'string'/ | stem spipeio.'

Catalog List

TSO LISTC

call outtrap 'lc.'                                  

'listc level(sys1)'                                 

call outtrap 'off'                                  

c = 0                                               

do i = 1 to lc.0                                     

  if wordpos(word(lc.i,1),'IN-CAT') > 0 then iterate

  c = c + 1                                         

  lcat.c = word(lc.i,3)                             

end                                                 

lcat.0 = c                                           

PIPE LISTCAT

"pipe listcat 'sys1' | stem cat."  

Productivity Summary

Here is a summary of the performance of the various techniques. The examples were run on a z15-T02 model A02 on a lightly-used LPAR under z/OS 2.5.

Retrieving a PDS member list of 2,523 members, all with ISPF statistics:

Technique

LOC

Service Units

Members

LISTDS

9

982

2,523

PIPE LISTPDS

1

644

2,523

ISPF Services

21

20,287

2,523

PIPE LISTISPF

1

1,064

2,523

Reading a data set (FB/80/32720) containing 19,756 records:

Technique

LOC

Service Units

Records Selected

EXECIO

9

1,328

19,756 

PIPE

1

3,005

19,756 

EXECIO Select

12

2,653

59    

PIPE Select

1

694

59    

Gathering a list of data sets (using the HLQ of SYS1)

Technique

LOC

Service Units

Datasets

LISTC

10

1,957

238

PIPE

1

97

238

Both the programmer’s effort and processing efficiency data show that using the TSO Pipelines commands yield significant improvements. Although the PIPE read of the entire data set uses more service units than EXECIO, it is significantly easier to code (one line versus nine).

Conclusion

Hopefully you have found these examples useful about the power of both REXX and TSO Pipelines. It is obvious that just the time saved by the programmer by coding a REXX program is an improvement over other methods. In addition, introducing TSO Pipelines in more complex scenarios demonstrates significant reductions in development time and system resource use. If you have access to TSO Pipelines in your z/OS environment, we recommend that you should take the time to learn it, as the time spent will pay for itself many times over. The best teacher is experimenting by writing your own code based on these examples.

If you have questions, please reach out to the authors via the IBM Community.

Authors' Comments on TSO Pipelines

Unfortunately, TSO Pipelines has not been updated for over two decades for the z/OS environment. Because of this, Pipelines in the z/OS environment does not have any awareness and thus support for features added since its latest release in 2000, including PDSE Version 2 member generations.

There has been an outstanding SHARE requirement to IBM to make TSO Pipelines available as part of the z/OS base for some time; it has one of the highest vote totals for currently open requirements. If you are interested, you can view and vote on the requirement at by visiting https://ibm-z-hardware-and-operating-systems.ideas.ibm.com/ideas/ZOS-I-3103.

The Pipelines product was originally developed for the VM/ESA CMS environment, was very well received, and today is an integral part of z/VM infrastructure. IBM also ported Pipelines to the IBM Z Netview product for use within that environment. The authors, and many others in the z/OS ecosystem, wonder why IBM hasn’t incorporated TSO Pipelines as part of the z/OS base distribution, given the obvious productivity gains demonstrated in the CMS and Netview environments.

About the authors

Ray Mullins is a Senior Software Developer at Trident Services, Inc. He has worked in the mainframe ecosystem for over 40 years, primarily with z/OS and predecessor operating systems. He has extensive experience with REXX and ISPF. He also works with z/VM and VSEⁿ operating systems.

Lionel Dyck is a Senior Software Developer at Trident Services, Inc. He has worked in the mainframe ecosystem for almost 50 years, primarily with z/OS and predecessor operating systems. He has extensive experience with REXX and ISPF and is a contributor to z/OS open source community (see Github, www.lbdsoftware.com, and several files at the CBT Tape).

#ibmchampions-highlights-home #ibmchampions-highlights