Wednesday, November 28, 2012

MVS JCL Reviewer Part 2

What is GDG (Generation Data Group)?

•    Generation Data Groups or GDG’s are a group of data sets which are related to each other chronologically and functionally.
•    These related Data Sets share a unique Data Set Name.
•    Every GDG data set has a Generation number and Version number assigned to each data set.

   EXAMPLE --       'MYLIB.LIB.TEST.G0001V00'
                                'MYLIB.LIB.TEST.G0002V00'
                                'MYLIB.LIB.TEST.G0003V00'     <-- Current Version


                                Generation Number ->  GaaaaVnn
                                                  aaaa is between 0000 to 9999
                                                  nn   is between 00   to 99


    In JCL:
            We refer current version with 0 
                Example.  MYLIB.LIB.TEST(0)
                            New version going to create with  +1    
                Example.  MYLIB.LIB.TEST(+1)
                            Older versions , refer with -1 -2 -3 etc....
                                              Example.  MYLIB.LIB.TEST(-1)   <- OLDER VERSION


•    Example for where we can use this GDGs: Usually, In production environment, for every month we need to run jobs to create reports for that month.

            Let us suppose     for JAN, We can code it  MYLIB.LIB.TEST.JAN
                                        for FEB, We can code it  MYLIB.LIB.TEST.FEB
                                        for MAR, We can code it  MYLIB.LIB.TEST.MAR
                                                 
So, every month we need change dataset name in JCL, before submitting the job. Whenever we entered into another year, we need to delete old year’s data sets.

 We need to do above task carefully, If we use GDG, It will take care following things

o    It will maintain all generation of data sets
o    It will delete/uncatalog older generation
o    Very easily, we can refer current and older versions of data sets
o    No need of change the JCL every time when we submit


How do you create a GDG?

•    Before using GDG, we need to create GDG index and model.


How do you create a GDG index?

•    IDCAMS (the 'AMS' stands for Access Method Services), utility is used to create GDG index.

•    Example JCL for creating GDG index.

           //MYJOB   JOB  (W234),’MYNAME’
           //STEP1   EXEC PGM=IDCAMS         
           //SYSIN   DD   *
             DEFINE GDG(NAME(MYLIB.LIB.TEST)    -
                        LIMIT(10)               -
                        NOEMPTY                 -
                        SCRATCH)
           /*
           //

           In this example, IDCAMS utility is used to create an index
           for a GDG called  MYLIB.LIB.TEST. The number of generations
           that can exist in this GDG is limited to ten. NOEMPTY parameter
           is used to specify , Once the limit is reached, the system is
           instructed to un-catalog the oldest generation data set within the
           GDG. SCRATCH parameter is used to specify to physically delete
           the data set which was un-catalogued.

    Parameters we can pass to IDCAMS.

o    NAME: This parameter is used to specify the name of the data set that is to be created.
o    LIMIT: This parameter is used to specify the total number of generations that the GDG may contain.
o    EMPTY/NOEMPTY: These two parameters are mutually exclusive. EMPTY specifies that all existing generations of the GDG are to be un-catalogued whenever the generations of GDG reached the maximum limit. NOEMPTY specifies that only the oldest generation of the GDG is to be un-catalogued if the limit is reached.
o    SCRATCH/NOSCRATCH: These two parameters are mutually exclusive. SCRATCH parameter specifies that whenever entry of the GDG is removed from the index, it should be deleted physically and catalogued.  NOSCRATCH parameter specifies that whenever entry of the GDG is removed from the index, it should be catalogued, not physically deleted.

        Note: SCRATCH and NOEMPTY are default parameters.


How do you create a GDG model?

•    Once the index has been created, a model data set must be created. This model data set contains specifications for the DCB sub-parameters for all data sets that will belong to that GDG. Programmer can override this default values if he want.

       EXAMPLE JCL

       //MYJOB  JOB   (W983),'TESTJOB'
       //STEP1  EXEC   PGM=IDCAMS
       //SYSIN  DD     *
         DEFINE GDG(                         -
                     NAME(MYLIB.LIB.TEST)    -
                     LIMIT(10)               -
                     NOEMPTY                 -
                     SCRATCH)
       //STEP2  EXEC PGM=IEFBR14
       //MODEL1 DD   DSN=MYLIB.LIB.TEST,
       //            DISP=(NEW,KEEP,DELETE),
       //            UNIT=SYSDA,
       //            SPACE(TRK,0),
       //            DCB=(LRECL=80,RECFM=FB,BLKSIZE=800)
       //

       Using IEFBR14, we have created the model.

          
How do you use a GDG?

•    To use created GDG in our JCL, we need to use name (with +1 for new generation) which we used in DEFINE GDG command. (i.e. MYLIB.LIB.TEST).

     EXAMPLE JCL       
      
     //MYJOB   JOB  (SD345),’MYNAME'
     //STEP1   EXEC PGM=COBPROG
     //INFILE  DD   DSN=MYLIB.LIB.TEST(+1),
     //             DISP=(NEW,CATLG,DELETE),
     //             UNIT=SYSDA,
     //             SPACE=(TRK,(20,10),RLSE),
     //             DCB=(MODEL.DCB,RECFM=FB,
     //             LRECL=80,
     //             BLKSIZE=800)
     //

     The program COBPROG is executed. A new generation data set is
     created via the statement

         //INFILE  DD  DSN=MYLIB.LIB.TEST(+1)

     Since we used (+1) with GDG name, it creates a new generation
     data set.

     The DISP parameter must be set to CATLG for all new generation
     data sets , DISP=(NEW,CATLG,DELETE)


     We used MODEL.DCB in DCB parameter to instruct system to use
     Sub-parameters specified in model GDG.

Note: The DSN and UNIT parameters must be coded for all new generation data sets.


In the JCL, In step1 it is going to create a new generation data set with name GDGNAME(+1). In step2, if you want to use same data set created from previous step? What number should you give to refer to that data set (i.e. 0 or +1 or +2)?   (STEP1 EXECUTED SUCCESSFULLY). Why?

•    Use number +1 to refer to the dataset created by the previous step.
•    Even step1 executed successfully, it is not become the current generation of GDG. At the end of the job only it will become the current version of GDG. So within the job we need to refer it as new generation only, even that step completed successfully. 

No comments:

Post a Comment