Try the following:

/* Rexx  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
/* determine the absolute generation of a GDG                        */
/* Execute the rexx passing it the GDG Base and the relative         */
/* generation number                                                 */
/* generation number                                                 */
/* ex ABSOLGDG GDGB(GDG BASE) GEN(0)                                 */
/* Note:  if you don't specify GEN, it will default to 0             */
/* ex ABSOLGDG GDGB(GDG BASE) GEN(0)                                 */
/*                                                                   */
Trace "N"
ddn  = "DDN"
gdgb = "SYSGM.CA.OPSMVS.DATASET.BACKUP"
gen  = "0"

parse upper arg 1 'GDGB(' gdgb ')'   ,
                1 'GEN(' gen ')'        ,
                1  parmstring

parse upper var parmstring parmstring
If Pos('DEBUG',parmstring) > 0 Then trace i

If gdgb = "" then
 do
   say ""
   say "GDG Base Missing, Rerun REXX and Specify GDGBASE(gdg base)"
   exit 16
 end

If gen = "" then
 do
   say ""
   say "GEN not specified, defaulting to relative generation zero"
   gen = 0
 end

rtrc = BPXWDYN("ALLOC FI(DDN) DA('" || gdgb || "("gen")')" ,
               " SHR REUSE  RTDSN(RTDSN) ")

if rtrc = 0 then
 do
   say ""
   say "Return Code from Dynamic Allocation:" rtrc
   say "Absolute Generation Dataset:" RTDSN
 end
else
 do
   say ""
   say "Error in allocating GDG, Dynamic allocation Return Code:" rtrc
 end

exit rtrc

Use the following JCL example:

//* ------------------------------------------------------------
//* executes absolgdg rexx to determine the absolute generation
//*
//*  %absolgdg gdgb(SYSGM.CA.OPSMVS.DATASET.BACKUP)
//*  %absolgdg gdgb(SYSGM.CA.OPSMVS.DATASET.BACKUP) gen(-2)
//*
//* ------------------------------------------------------------
//JS020    EXEC PGM=IKJEFT1B
//SYSEXEC   DD DISP=SHR,DSN=VZWX4J.REXX.EXEC
//SYSTSPRT  DD SYSOUT=(,)
//SYSTSIN   DD *
 %absolgdg gdgb(SYSGM.CA.OPSMVS.DATASET.BACKUP)
 %absolgdg gdgb(SYSGM.CA.OPSMVS.DATASET.BACKUP) gen(-2)
//

Let me know if this helps or if you need changes.

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [email protected] with the message: INFO IBM-MAIN

Reply via email to