Search code examples
mainframezosjcl

how to get current GDG version through jcl


I have a code below to write the properties of the gdg to a PS file.

//STEP10  EXEC PGM=IDCAMS                              
//DD1       DD DSN='GDGBASE(0)',DISP=SHR  
//SYSPRINT  DD DSN=GDG.VERSION.PS,           
//             DISP=(NEW,CATLG,DELETE),                
//             UNIT=WORK,AVGREC=K,                     
//             SPACE=(108,(5,5),RLSE),                 
//             DCB=(BUFNO=10,RECFM=FB,LRECL=108)       
//SYSIN     DD *                                       
 PRINT INFILE(DD1) COUNT(0) CHAR                       
/*   

But I just need the GDG's latest version name to be written in to the PS file.


Solution

  • I don't think you can do this using pure JCL. As a suggestion to get you started here's a short REXX and some JCL - it's not perfect, but you can tune it to fit your specific needs.

    Part 1: a short REXX-script to display the DSN of an allocated file:

    /* REXX find DSN for DD */ 
    arg mydd                     
    x= LISTDSI(mydd file)        
    say sysdsname                
    

    Part 2: JCL to invoke it using batch-TSO:

    //FINDDSN EXEC PGM=IKJEFT01,PARM='DSNFIND MYFILE'    
    //MYFILE   DD  DSN=MY.GDG.FILE(+0),DISP=SHR    
    //SYSEXEC  DD  DSN=PDS.CONTAINING.REXX,DISP=SHR          
    //SYSTSPRT DD  SYSOUT=*                                
    //SYSTSIN  DD  DUMMY
    

    where DSNFIND is the membername of the given REXX-procedure.

    Output in SYSTSPRT is:

    MY.GDG.FILE.G0338V00
    READY                       
    END                     
    

    I haven't found a quick way to suppress the READY and END - but instead of SAY you could e.g. use EXECIO to write to an other file - READY and END would still go to SYSTSPRT.