title: IDCAMS LISTCAT deleting VSAM file when next step is IEFBR14
body: <p>I have a requirement wherein I need to check if a VSAM file exists or not. If it is not present then I need to create it like TEST.FILE2. My JCL is as : </p>
  
  <pre><code>//STEP01   EXEC PGM=IDCAMS                           
  //SYSPRINT DD  SYSOUT=*                              
  //SYSIN    DD  *                                     
    LISTCAT ENTRIES('BRTEST.FILE1') 
  /*                                                   
  //STEP02 EXEC PGM=IEFBR14,COND=(4,GT)                
  //DD01     DD DSN=BRTEST.FILE1,   
  //            DISP=(,CATLG,DELETE),                  
  //            LIKE=BRTEST.FILE2
  //SYSPRINT DD  SYSOUT=*                              
  //SYSOUT   DD  SYSOUT=*                    
  </code></pre>
  
  <p>But a stange thing is happening. Whenever I execute this JCL, STEP001 return a return code as 004 even though the file is already present, and a new file is created in STEP02. So if I submit this JCL twice, a new file is created both the times. I am not able to understand how the file is getting deleted. And the strange thing is if I run the JCL without STEP02 then it gives MAXCC as 0 saying that the file was found in catalog.           </p>
  
  <p>I was able to achieve my requirement by following code, but would still like to understand why and how my VSAM file gets deleted for LISTCAT. </p>
  
  <pre><code>//STEP02 EXEC PGM=IEFBR14,COND=(4,GT)                
  //DD01     DD DSN=BRTEST.FILE1,   
  //            DISP=(MOD,CATLG,CATLG),                  
  //            LIKE=BRTEST.FILE2
  //SYSPRINT DD  SYSOUT=*                              
  //SYSOUT   DD  SYSOUT=*  
  </code></pre>
  
  <p>Here is the SYSPRINT when only STEP01 is executed:</p>
  
  <pre><code>IDCAMS  SYSTEM SERVICES                                           TIME: 03:47:44
  
    LISTCAT ENTRIES('BRTEST.FILE1')                                               
  CLUSTER ------- BRTEST.FILE1                                                    
       IN-CAT --- CATALOG.TEST03                                                  
     DATA ------- BRTEST.FILE1.DATA                                               
       IN-CAT --- CATALOG.TEST03                                                  
     INDEX ------ BRTEST.FILE1.INDEX                                              
       IN-CAT --- CATALOG.TEST03                                                  
  IDCAMS  SYSTEM SERVICES                                           TIME: 03:47:44
           THE NUMBER OF ENTRIES PROCESSED WAS:                                   
                     AIX -------------------0                                     
                     ALIAS -----------------0                                     
                     CLUSTER ---------------1                                     
                     DATA ------------------1                                     
                     GDG -------------------0                                     
                     INDEX -----------------1                                     
                     NONVSAM ---------------0                                     
                     PAGESPACE -------------0                                     
                     PATH ------------------0                                     
                     SPACE -----------------0                                     
                     USERCATALOG -----------0                                     
                     TAPELIBRARY -----------0                                     
                     TAPEVOLUME ------------0                                     
                     TOTAL -----------------3                                     
           THE NUMBER OF PROTECTED ENTRIES SUPPRESSED WAS 0                       
  IDC0001I FUNCTION COMPLETED, HIGHEST CONDITION CODE WAS 0                       
  
  IDC0002I IDCAMS PROCESSING COMPLETE. MAXIMUM CONDITION CODE WAS 0 
  </code></pre>
  
  <p>And when both steps are executed:</p>
  
  <pre><code>IDCAMS  SYSTEM SERVICES                                           TIME: 03:48:35
  
    LISTCAT ENTRIES('BRTEST.FILE1')                                               
  IDC3012I ENTRY BRTEST.FILE1 NOT FOUND                                           
  IDC3009I ** VSAM CATALOG RETURN CODE IS 8 - REASON CODE IS IGG0CLEG-42          
  IDC1566I ** BRTEST.FILE1 NOT LISTED                                             
  IDCAMS  SYSTEM SERVICES                                           TIME: 03:48:35
           THE NUMBER OF ENTRIES PROCESSED WAS:                                   
                     AIX -------------------0                                     
                     ALIAS -----------------0                                     
                     CLUSTER ---------------0                                     
                     DATA ------------------0                                     
                     GDG -------------------0                                     
                     INDEX -----------------0                                     
                     NONVSAM ---------------0                                     
                     PAGESPACE -------------0                                     
                     PATH ------------------0                                     
                     SPACE -----------------0                                     
                     USERCATALOG -----------0                                     
                     TAPELIBRARY -----------0                                     
                     TAPEVOLUME ------------0                                     
                     TOTAL -----------------0                                     
           THE NUMBER OF PROTECTED ENTRIES SUPPRESSED WAS 0                       
  IDC0001I FUNCTION COMPLETED, HIGHEST CONDITION CODE WAS 4                       
  
  IDC0002I IDCAMS PROCESSING COMPLETE. MAXIMUM CONDITION CODE WAS 4               
  </code></pre>
  
  <p>The value for ZOS390RL variable is z/OS   02.01.00 and ZENVIR is ISPF 7.1MVS     TSO.</p>