On Thu, 25 Jul 2019 14:47:13 -0500, John McKown <john.archie.mck...@gmail.com> 
wrote:

>I just don't see any _simple_ way to do this. I need to convert the
>gdgbase(0) into gdgbase.GnnnnVnn absolute. Believe it or not, I have a
>product which creates a number of PDS libraries (not PDSE) which are GDG. I
>want to generate some JCL which is the equivalent of:
>
>//SYSUT1 DD DISP=SHR,DSN=GDGBASE(0)(MEMBER)
>
>Which is a JCL error.
>
>--
>A sine curve goes off to infinity, or at least the end of the blackboard.
>-- Prof. Steiner
>
>Maranatha! <><
>John McKown

John, here is a REXX Function that will do what you want.  It uses LISTCAT and 
is based on another function that I wrote that also retrieves some other 
information on the specified GDG Data Set.  Since you were only interested in 
the Absolute GDG Data Set  Name, I removed the other code and simplified the 
function.  Enjoy!

/*------------------------------ GETGDG ------------------------------*/
/* Get the Absolute Generation for a specified Relative Generation.   */
/* Format:   GETGDG dsn                                               */
/* Where:    dsn - GDG Data Set Name with Relative Generation Number: */
/*                 (0) (+0) (-n)                                      */
/*           hlq.dsn1(+0)  hlq.dsn2(-4)  hlq.dsn3(0)                  */
/* Returns:  Return Code 0 followed by GDG Data Set Name with the     */
/*           Absolute Generation Number:  0 hlq.dsn1.GnnnnVnn         */
/*           Error Return Code and no DSN if a problem occurs:  n     */
/*           Return Code of 2 indicates a missing/invalid DSN.        */
/* Examples: Parse Value GETGDG('HLQ.DSN.GDG(+0)') With src absdsn .  */
/*           If src   \= 0  Then (error processing)                   */
/*           If absdsn = '' Then (error processing)                   */
/*                                                                    */
/*           dsn = 'HLQ.BASE.GDG(-2)'                                 */
/*           Parse Value GETGDG(dsn) With src olddsn .                */
/*           If src   \= 0  Then (error processing)                   */
/*           If olddsn = '' Then (error processing)                   */
/*--------------------------------------------------------------------*/
GETGDG:  Procedure                                                      
   Arg dsn .                                                            
   If dsn = '' Then Return 2                                            
   If Pos('.',dsn) = 0 Then Return 2                                    
   Parse Var dsn dsn . '(' gen . ')' .                                  
   If gen = '' Then Return 2               
   cmd = "LISTCAT ENTRIES('"dsn"') GDG ALL"
   Call OutTrap 'REC.'                     
   cmd                                     
   src = rc                                
   Call OutTrap 'OFF'                      
   If src \= 0 Then                        
      Do                                   
         If rec.0 > 0 Then Say rec.1       
         Return src                        
      End                                  
   If rec.0 = 0 Then Return 8              
   osdsn = ''                              
   num = Abs(gen) + 1                      
   m = 0                                   
   Do s = rec.0 to 1 by -1                 
      Parse Var rec.s type . '--' value .  
      If type \= 'NONVSAM' Then Iterate s  
      m = m + 1                            
      If num = m Then                      
         Do                                
            osdsn = value                  
            Leave s                        
         End                         
   End /* Do s = rec.0 to 1 by -1 */ 
   Drop rec.                         
   If osdsn = '' Then Return 12      
   Return 0 osdsn                    

-- 
Dale R. Smith 

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN

Reply via email to