How to tell if a member of a PDS/PDSE exists in an ESP REXX routine ?
search cancel

How to tell if a member of a PDS/PDSE exists in an ESP REXX routine ?

book

Article ID: 53523

calendar_today

Updated On:

Products

ESP Workload Automation

Issue/Introduction

In an ESP REXX routine, how can you tell if a member of a PDS/PDSE exists?

 

Environment

Release: All
Component: ESP Workload Automation

Resolution

If you use ALLOCX to allocate the member name it will always pass cc=4, just like IBM's TSO ALLOC. So this method will not work. If you then try to use a REXX EXECIO, an abend code will be returned from the REXX.

The following is a method to test if a member exists using the IBM utility IEBCOPY. You can also use the utility IEBGENER. Additionally, you could also use IEHLIST to list all the members, but this requires the current volser of the dataset.

Example of using IEBCOPY to copy the member to another dataset and trap the return code to a variable:

REXXON GEN                                                
"VTDELETE OVERRIDE"                                       
"INTEGER COPY"                                            
 
"VTDEFINE OVERRIDE"                                       
"FREEX F(DD1)"                                            
"FREEX F(DD2)"                                            
"FREEX F(SYSIN)"                                          
"FREEX F(SYSPRINT)"                                       
"ALLOCX F(DD1) DSN('MYHLQ.ESP.PROC') SH "               
"ALLOCX F(DD2) DSN('MYHLQ.CNTL') SH "                   
"ALLOCX F(SYSIN) DSN('MYHLQ.CNTL(COPY)') SH "           
"ALLOCX F(SYSPRINT) DSN('MYHLQ.CNTL(SYSPRINT)') SH "    
ADDRESS LINKPGM "IEBCOPY"                                 
"COPY = '"RC"'"                                           
"FREEX F(DD1)"                                            
"FREEX F(DD2)"                                            
"FREEX F(SYSIN)"                                          
"FREEX F(SYSPRINT)"                                        
 
"MSG  = 'TEST PDS'"                                    
 
"VPUT (MSG) TABLE(OVERRIDE) CLANG"                        
"VPUT (COPY) TABLE(OVERRIDE) CLANG"                       
REXXOFF                                                   
VGET (MSG) TABLE(OVERRIDE) CLANG                          
VGET (COPY) TABLE(OVERRIDE) CLANG