In a CA ESP Workload Automation REXX routine how can you tell if a member of a PDS/PDSE exists?

Document ID : KB000053523
Last Modified Date : 14/02/2018
Show Technical Document Details

Description:

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

Solution:

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('ROZRIA1.ESP.PROC') SH "               
"ALLOCX F(DD2) DSN('ROZRIA1.CNTL') SH "                   
"ALLOCX F(SYSIN) DSN('ROZRIA1.CNTL(COPY)') SH "           
"ALLOCX F(SYSPRINT) DSN('ROZRIA1.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