JCL

GDG – Generation Data Groups operations in JCL

GDG Stands for ‘Generation data group’ & is used to catalog a group of datasets that have common and similar data formats, and these datasets can be referenced by relative generation and version number. It is mostly used to take periodic backups of critical data for future reference. 

All datasets within GDG share the same name except the last qualifier which is made of generation number and version number. The individual files within a group have a generation number added to the end of the name to make each file name unique. e.g. if the base is “XXXXX.YYYYY.ZZZZZ” then the first file created will be given the name “XXXXX.YYYYY.ZZZZZ.G0001V00″. Subsequent files are named by incrementing the generation number resulting in filenames ending in G0002V00 through G9999V00. Once the G9999V00 is reached the numbering will start again from G0001V00. 

  • G – Stands for Generation number – Value range 0000 – 9999
  • V – Stands for Version number – Value range 00 – 99
  • The two zeroes on the end of the name are used to represent a volume number.

Rules for coding GDG

  • All datasets belonging to a GDG must have same DCB parameters such as record length, record format and so on.
  • Maximum of 255 datasets can exist within a GDG
  • GDGs must be cataloged
  • Generations of GDG should be sequential and must reside on disk or tape
  • For all new generation data sets, DISP parameter must be set to CATLG
  • For all new generation data sets, DSN and UNIT parameter must be coded

The benefits are

  • We do not need to create a new JCL or change the name of the JCL every time in a weekly run or daily run or monthly run or yearly run of a JCL.
  • You can set the limit of the related files(generations)
  • We can easily keep track of all generation of data sets
  • We can delete or un-catalog the older generation
  • Any particular generation can be referred easily.

Note: Generations are updated only at the end of the job i.e. For any executing job, the current generation remains the same until it ends. If the job abends then the next version is also not created.

Create a GDG Base using IDCAMS

In this example 20 is the number of generations to create and keep.

 //STEP1 EXEC PGM=IDCAMS
 //SYSPRINT DD SYSOUT=*
 //SYSIN DD *
 DEFINE GDG(NAME(XXXXX.YYYYY.ZZZZZ.GDGVER) -
 LIMIT(20) -
 NOEMPTY -
 SCRATCH)
 /*

NAME – This parameter is used to specify the name of the data set that is to be created.
LIMIT – This parameter is used to specify the total number of generations that the GDG may contain. The maximum value for LIMIT is 255. 
EMPTY/NOEMPTY – These two parameters are mutually exclusive. EMPTY specifies that all existing generations of the GDG are to be uncataloged whenever the generations of GDG reached the maximum limit i.e. let’s say the limit is defined as 5 and we are creating the 6th version. In this case version, 1 will be uncataloged while creating the 6th version. NOEMPTY specifies that only the oldest generation of the GDG is to be uncataloged if the limit is reached i.e. let’s say the limit is defined as 5 and we are creating the 6th version. In this case version, 1 to 5 will be uncataloged while creating the 6th version.
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 uncataloged. NOSCRATCH parameter specifies that whenever entry of the GDG is removed from the index, it should be uncataloged, not physically deleted.

Create a model or template

Once the index has been created, a model data set must be created. This model data set contains specifications for the DCB subparameters for all data sets that will belong to that GDG. Programmers can override these default values if they want.

 //STEP010 EXEC PGM=IDCAMS
 //SYSPRINT DD SYSOUT=*
 //SYSIN DD *
 DEFINE GDG(NAME(XXXXX.YYYYY.ZZZZZ.GDGMODL) -
 LIMIT(20) -
 NOEMPTY -
 SCRATCH)
 /*
 //STEP020 EXEC PGM=IEFBR14 
 //GDGMODEL DD DSN=XXXXX.YYYYY.ZZZZZ.GDGMODL, 
 //         DISP=(NEW,KEEP,DELETE), 
 //         UNIT=SYSDA, 
 //         SPACE=(TRK,15), 
 //         DCB=(LRECL=80,RECFM=FB,BLKSIZE=0,DSORG=PS)

Generate GDG versions

 //GENGDG EXEC PGM=IEBGENER
 //SYSPRINT DD SYSOUT=*
 //SYSIN DD DUMMY
 //SYSUT1 DD *
   DATA LINE 1
   DATA LINE 2
   DATA LINE 3
   DATA LINE 4
   DATA LINE 5
 /*
 //SYSUT2 DD DSN=XXXXX.YYYYY.ZZZZZ.GDGVER(+1),
 //       DISP=(NEW,CATLG,DELETE),
 //       SPACE=(TRK,15),
 //       DCB=XXXXX.YYYYY.ZZZZZ.GDGMODEL

Create a new Generations

You can create a new generation by using below mentioned JCL.

 //COPYLOG EXEC PGM=IEBGENER 
 //SYSPRINT DD SYSOUT=* 
 //SYSUT1 DD DSN=XXXXX.YYYYY.ZZZZZ.DATA,
 //       DISP=SHR 
 //SYSUT2 DD DSN=XXXXX.YYYYY.ZZZZZ.DATAGDG(+1),
 //       DISP=(NEW,CATLG,DELETE),
 //       SPACE=(TRK,15), 
 //       DCB=XXXXX.YYYYY.ZZZZZ.GDGMODEL 
 //SYSIN DD DUMMY 
 //SYSOUT DD SYSOUT=*
 //SYSUDUMP DD SYSOUT=*

Concatenating GDG Versions

As shown below, when we have to use generation data sets associated with the group as a single, contiguous file, we can specify the GDG index name without brackets ().

//STEPNAME EXEC PGM=IDCAMS
//SYSPRINT DD *
//SYSUT1   DD DSN=XXXXX.YYYYY.ZZZZZ.SALES.MONTHLY,  <--Concatenated generations
//SYSUT2   DD DSN=XXXXX.YYYYY.ZZZZZ.SALES.MONTHLY.PSBKUP,
//            DISP=(NEW,CATLG,DELETE),
//            UNIT=PROD,SPACE=(CYL(2,2),RLSE),
//            DCB=(LRECL=80,RECFM=FB,
//                  BLKSIZE=0,DSORG=PS)
//SYSIN    DD *
  REPRO INFILE(SYSUT1) OUTFILE(SYSUT2)
/*

Delete GDG Versions

If you need to delete your base & delete the individual data sets (G0001V00, G0002V00, etc.) and then run this IDCAM job to delete the GDG.

If you want to DELETE base, then you can use either DELETE GDG FORCE or  DELETE GDG PURGE. You can give any one of these options in IDCAMS utility –

  • DELETE PURGE – If you want to delete GDG Base or Index even if retention period(RETP) or expiry date is over, then you can use this option.
  • DELETE FORCE – To delete the GDG index and all the generations forcefully, you can use this option.
 //GDGDLTE EXEC PGM=IDCAMS 
 //SYSPRINT DD SYSOUT=* 
 //SYSIN DD *  
   DELETE (XXXXX.YYYYY.ZZZZZ.GDGVER) GDG FORCE
 /*
 //GDGDLTE EXEC PGM=IDCAMS 
 //SYSPRINT DD SYSOUT=* 
 //SYSIN DD *  
   DELETE (XXXXX.YYYYY.ZZZZZ.GDGVER) GDG PURGE
 /*

If you want to delete a particular Generation of a GDG or simply delete all generations, then –

//GDGDLTE   EXEC PGM=IEFBR14  
//GDGDEL     DD  DSN=XXXXX.YYYYY.ZZZZZ.GDGVER(0),  
//           DISP=(OLD,DELETE,DELETE)

Delete the GDG model

 //GDGMODDL EXEC PGM=IEFBR14
 //GDGMODEL DD  DSN=XXXXX.YYYYY.ZZZZZ.GDGMODEL,
 //             DISP=(MOD,DELETE,DELETE),
 //             UNIT=SYSDA,
 //             SPACE=(TRK,0),
 //             DCB=(LRECL=80,RECFM=FB,BLKSIZE=800,DSORG=PS)

Alter the number of GDG generations   

This example of a GDG was created with 15 generations of data sets using the LIMIT(15) parameter. If you wish to change the number of generations run this IDCAMS alter example where the number of generations is increased to 50. Use the name in the ALTER statement            

 //STEP1    EXEC  PGM=IDCAMS                                   
 //SYSPRINT DD    SYSOUT=A                                     
 //SYSIN    DD    *                                            
      ALTER XXXXX.YYYYY.ZZZZZ.GDGVER -                                  
      LIMIT(50)            -
      NOEMPTY – 
      SCRATCH                                        
  /* 

Overriding GDG generations

For testing purposes or for a production incident resolution/re-run, you might need to use different datasets or GDG versions other than the ones specified in the cataloged procedure. In that case, the dataset in the procedure can be overridden in the JCL as mentioned below where we are overriding (-1) version of XXXXX.YYYYY.ZZZZZ.DATAGDG.

//STEPXX    EXEC MYPROC
//STEP1.SORTIN DD DSN=XXXXX.YYYYY.ZZZZZ.DATAGDG(-1),DISP=SHR
//*


//* STEP1 of PROC MYPROC is givenbelow
.....
.....
//STEP1     EXEC PGM=SORT
//SORTIN   DD DSN=XXXXX.YYYYY.ZZZZZ.DATAGDG(0),DISP=SHR
//SORTOUT  DD DSN= XXXXX.YYYYY.OUTPUT(+1), 
//         DISP=(NEW,CATLG,DELETE),UNIT=3390,   
//         SPACE=(CYL,(5,1)),DCB=(LRECL=22) 
//SYSOUT    DD SYSOUT=*
//SYSIN    DD *                        
  OMIT COND=(5,1,CH,EQ,C'M')                   
  SORT FIELDS=(20,8,CH,A,10,3,FI,D)            
  SUM FIELDS=(16,4,ZD)                 
  OPTION DYNALLOC,ZDPRINT          
  OUTREC FIELDS=(10,3,20,8,16,4,2Z,5,1,C' SUM')   
/*

Include Omit Condition: Click Here SYNCSORT Manual: Click Here

Admin

Share
Published by
Admin

Recent Posts

Increase Transparency and Collaboration Product Backlog

A well-maintained product backlog is crucial for successful product development. It serves as a single…

3 weeks ago

Product Backlog – Incremental value to the customer

Incremental value to the customer refers to the gradual delivery of small, functional parts of…

4 weeks ago

Product Market, Customer’s Desire, Need, and Challenges

A Product Market refers to the group of potential customers who might be interested in…

4 weeks ago

PAL-EBM Professional Agile Leadership – EBM Certification

The Professional Agile Leadership - Evidence-Based Management (PAL-EBM) certification offered by Scrum.org is designed for…

4 months ago

PAL I Professional Agile Leadership Certification

The Professional Agile Leadership (PAL I) certification, offered by Scrum.org, is designed to equip leaders…

4 months ago

Scrum Master Certification: CSM, PSM, SSM

Choosing the right Scrum Master Certification depends on your current experience and career goals. If…

6 months ago