What is generation data group (GDG)

A generation data group (GDG) is a collection of historically related non-VSAM data sets that are arranged in chronological order. That is, each data set is historically related to the others in the group. Each data set within a GDG is called a generation or generation data set (GDS).

A Generation Data Group (GDG) is used for processing data sets that are  created on a periodical basis – monthly or weekly or daily or hourly. In each processing cycle, a new generation of the dataset is generated.

For example, GDG can be used to:

  • Invoicing
  • Reporting
  • Backup
  • Statistics
  • Audit Trails

As the name suggests, each new data set that is created forms a new "generation" in a series. Generation data groups typically follow this pattern:

  • A new generation of the data set is added.
  • Some of the previous generations of the data set are retained (depending on condition).
  • The oldest generation of the data set is deleted or backed up  (depending on condition).

The advantage of using generation data groups (GDG) is that the system keeps track of the generations for you so you don't have to change your JCL each time you run.

To simply put, GDGs are:

  • Is a group of datasets related to each other chronologically or functionally.
  • It provides way of grouping together related data sets that share similar functional or physical properties.
  • Generations of a GDG can reside on DASD or TAPE or both.
  • Upto 255 relative generations can exist and must be cataloged.

For example lets consider a monthly report generation when created using normal dataset vs GDG:

With normal data set names With generation data group names Dataset Version
REPORT.DEC.DATA REPORT.DATA(0) current report
REPORT.NOV.DATA REPORT.DATA(-1) Previous month report
REPORT.OCT.DATA REPORT.DATA(-2) older report


To add a new generation to a generation data group, you just create a data set with the same name as before and +1 for the generation:


//STEPCRTE EXEC PGM=IEFBR14
//DD1 DD DSN=REPORT.DATA(+1),
// DISP=(NEW,CATLG),
// SPACE=(TRK,(1,5),
// DCB=PROGPUB.MODL.MODL

The system then changes all the previous generation names so that the old (0) becomes (-1), the old (-1) becomes (-2), etc. Here's an example:

Before job completes: After job completes:
REPORT.DATA(+1) REPORT.DATA(0)
REPORT.DATA(0) REPORT.DATA(-1)
REPORT.DATA(-1) REPORT.DATA(-2)
REPORT.DATA(-2) Deleted--if only 3 generations were to be kept


To make things consistent within a given job, generation data group numbers are not updated at the end of the job step in which a new generation is created. Instead, they are updated at the end of the job. This is important to as (+1) throughout the job.

In the system catalog, each generation has a name with its ‘absolute generation number’


GDGname.GaaaaVnn  where
aaaa – absolute generation number from 0001 to 9999
nn – version number from 00 to 99

Creating and Using Generation Data Group (GDG)

To create a generation data group, you must first do these two things:

  1. Create an entry for the GDG in the system catalog. This entry is called the GDG Base - PROGPUB.BASE.GDG. This entry names the generation data group and specifies how many generations to keep.
  2. For non-SMS managed datasets, the second step involves creating a model dataset for supplying the DCB parameters to the new individual dataset belonging to a group. This model dataset must be cataloged. For SMS managed datasets, this step can be bypassed.
  3. To Create a GDG Dataset we can use both IDCAMS & IEHPROGM

Creating a Generation Data Group Base Entry:

Sets up the catalog entry used to keep track of the generation data group (GDG) generations.

  • Names the generation data group.
  • Specifies how many generations are to be kept.
  • Instructs what to do with old generations.
  • As an option, tells how long to keep the entire generation data group.
  • You create a generation data group base entry by executing a VSAM utility program called IDCAMS with DEFINE command. Here is an example:

//PROGPUBA JOB NOTIFY=PROGPUB
//STEP010 EXEC PGM=IDCAMS
//SYSPRINT DD SYSOUT=*
//SYSIN DD *
  DEFINE GDG(NAME(PROGPUB.BASE.GDG)-
  LIMIT(3)-
  EMPTYSCRATCH)
/*
//

The VSAM utility programs have a different syntax from the regular utility programs, which in turn are different from JCL. The dash at the end of a line continues a statement only for the VSAM utilities. Here's an explanation for the DEFINE statement used to create a generation data group base entry:

NAME A GDG name can contain maximum of 35 characters (Since the GnnnnV00 take up 9 positions we have to keep the name to 35 or less characters)
LIMIT Specifies how many GDS's (generations) are to be maintained in a group. (Maximum 255)
EMPTY / NOEMPTY Specifies what action OS should take when the LIMIT value is reached. EMPTY means that all generations should be removed (uncatalogued) from the group; NOEMPTY means that just the oldest generation should be removed (uncatalogued). NOEMPTY is the default
SCRATCH / NOSCRATCH Specifies whether or not OS should scratch (physical deletion) GDS's as they are removed from the group. NOSCRATCH is the default
OWNER Specifies 1 to 6 character owner-id for the GDG.
TO & FOR Specifies the expiration date TO(yyyyddd) or a retention period FOR(dddd) for the GDG


Creating the Model:

Use the IEFBR14 utility to create a MODEL. Actually, the system doesn't need an entire data set. It just requires the DCB information contained in the dataset label.


//STEP020 EXEC PGM=IEFBR14
//DD1 DD DSN=PROGPUB.MODL,
// DISP=(NEW,CATLG),
// SPACE=(TRK,0),
// DCB=(LRECL=80,RECFM=FB)

From this JCL the system can use the DCB values given in the model as default values when a new GDS is created. The DCB values can also be overidden while creating the new GDS.

Creating the new generation dataset:

To create a new data set for a generation data group, you provide the generation number for the new generation. Use IEFBR14 utility or a user-written application program.


//STEP020 EXEC PGM=IEFBR14
//DD1 DD DSN=PROGPUB.MODL,
// DISP=(NEW,CATLG),
// SPACE=(TRK,0),
// DCB=(LRECL=80,RECFM=FB)

Points to remember when creating a new data set for a generation data group are:

  • DSN should be coded for new generations, along with the generation number in parentheses.
  • Disposition should be CATLG for all new generations.
  • Generations are referred by the same generation number throughout the various steps in the job as the system updates the generation number only when the job terminates.
  • After the job terminates a new generation is added to the GDG and becomes the current generation.
  • The former current generation becomes a previous generation.
  • Relative generation number is used to uniquely identify every data set in the GDG.
  • The current generation is identified as DSN=GDGname(0).
  • The earlier generation is identified as DSN=GDGname(-1) and the second oldest generation is identified as DSN=GDGname(-2) and so on.
  • +ve numbers refer to generations which are not yet created: Example,
    • DSN=GDGname(+1)
    • DSN=GDGname(+2),.....).

Absolute and Relative generation numbers:

Lets consider this example with 3 generations in the catalog

GDG Generation Absolute generation number Relative generation number
PROGPUB.BASE.GDG Base GDG

PROGPUB.BASE.GDG.G0001V00 OLDEST GENERATION G0001V00 (-2)
PROGPUB.BASE.GDG.G0002V00 PREVIOUS GENERATION G0002V00 (-1)
PROGPUB.BASE.GDG.G0003V00 CURRENT GENERATION G0003V00 (0)


How to retriev a generation dataset:

To retrieve an individual dataset, code the dataset name along with the relative generation number.

If the dataset is coded without the generation number, then all the generations in that group will be concatenated and retrieved.

Deleting a generation dataset:

The system will automatically delete the individual GDS as per the GDG base ‘definition’.
We can also delete a specific generation by coding DISP=(Old,Delete). To delete the GDG Base we have to use IDCAMS command.

GDG Example JCLs:

Base Index GDG JCL example:


   File  Edit  Edit_Settings  Menu  Utilities  Compilers  Test  Help            
 -------------------------------------------------------------------------------
 EDIT       PROGPUB.AA.SOURCE(IDXGDJCL) - 01.03            Columns 00001 00072 
 ****** ***************************** Top of Data ******************************
 ==MSG> -Warning- The UNDO command is not available until you change            
 ==MSG>           your edit profile using the command RECOVERY ON.              
 000001 //PROGPUBA JOB NOTIFY=PROGPUB                                           
 000002 //S1 EXEC PGM=IDCAMS                                                    
 000003 //SYSPRINT DD SYSOUT=*                                                  
 000004 //SYSIN DD *                                                            
 000005    DEFINE GDG(NAME(PROGPUB.AA.GDGRPT)-                                 
 000006        LIMIT(5)-                                                        
 000007        SCRATCH)                                                         
 000008 /*                                                                      
 000009 //                                                                      
 ****** **************************** Bottom of Data ****************************

Create new generation GDG JCL example:


    File  Edit  Edit_Settings  Menu  Utilities  Compilers  Test  Help            
 -------------------------------------------------------------------------------
 EDIT       PROGPUB.AA.SOURCE(CRGDGJCL) - 01.05              Columns 00001 00072 
 ****** ***************************** Top of Data ******************************
 ==MSG> -Warning- The UNDO command is not available until you change            
 ==MSG>           your edit profile using the command RECOVERY ON.              
 000001 //PROGPUBA JOB NOTIFY=PROGPUB                                           
 000002 //S1 EXEC PGM=IEFBR14                                                   
 000003 //DD1 DD DSN=PROGPUB.AA.GDGRPT(+1),DISP=(NEW,CATLG,DELETE),            
 000004 //       SPACE=(TRK,(8,5),RLSE),                                        
 000005 //       DCB=PROGPUB.AA.MDL,                                           
 000006 //       UNIT=SYSDA                                     
 000007 //SYSIN DD DUMMY                                                        
 000008 //                                                                      
 ****** **************************** Bottom of Data ****************************

Alter GDG base JCL example:


    File  Edit  Edit_Settings  Menu  Utilities  Compilers  Test  Help            
 -------------------------------------------------------------------------------
 EDIT       PROGPUB.AA.SOURCE(ALGDGJCL) - 01.00             Columns 00001 00072 
 ****** ***************************** Top of Data ******************************
 ==MSG> -Warning- The UNDO command is not available until you change            
 ==MSG>           your edit profile using the command RECOVERY ON.              
 000001 //PROGPUBA JOB NOTIFY=PROGPUB                                           
 000002 //S1 EXEC PGM=IDCAMS                                                    
 000003 //SYSPRINT DD SYSOUT=*                                                  
 000004 //SYSIN DD *                                                            
 000005    ALTER PROGPUB.AA.GDGRPT EMPTY                                       
 000006 /*                                                                      
 000007 //                                                                      
 ****** **************************** Bottom of Data ****************************

Delete GDG base JCL example:


   File  Edit  Edit_Settings  Menu  Utilities  Compilers  Test  Help            
 -------------------------------------------------------------------------------
 EDIT       PROGPUB.AA.SOURCE(DLGDGJCL) - 01.02              Columns 00001 00072 
 ****** ***************************** Top of Data ******************************
 ==MSG> -Warning- The UNDO command is not available until you change            
 ==MSG>           your edit profile using the command RECOVERY ON.              
 000001 //PROGPUBA JOB NOTIFY=PROGPUB                                           
 000002 //S1 EXEC PGM=IDCAMS                                                    
 000003 //SYSPRINT DD SYSOUT=*                                                  
 000004 //SYSIN DD *                                                            
 000005    DELETE PROGPUB.AA.GDGRPT GDG FORCE                                  
 000006 /*                                                                      
 000007 //                                                                      
 ****** **************************** Bottom of Data ****************************

Merge GDG JCL example:


   File  Edit  Edit_Settings  Menu  Utilities  Compilers  Test  Help            
 -------------------------------------------------------------------------------
 EDIT       PROGPUB.AA.SOURCE(MGGDGJCL) - 01.02              Columns 00001 00072 
 ****** ***************************** Top of Data ******************************
 ==MSG> -Warning- The UNDO command is not available until you change            
 ==MSG>           your edit profile using the command RECOVERY ON.              
 000001 //PROGPUBA JOB NOTIFY=PROGPUB                                           
 000002 //S1 EXEC PGM=ICETOOL                                                   
 000003 //TOOLMSG DD SYSOUT=*                                                   
 000004 //DFSMSG DD SYSOUT=*                                                    
 000005 //IN1 DD DSN=PROGPUB.AA.GDG1,DISP=SHR                                
 000006 //    DD DSN=PROGPUB.AA.GDG2,DISP=SHR                                
 000007 //OUT DD DSN=PROGPUB.AA.GDG3,DISP=SHR                                
 000008 //TOOLIN DD *                                                           
 000009  SORT FROM(IN1) TO(OUT) USING(CTL1)                                     
 000010 /*                                                                      
 000011 //CTL1CNTL DD *                                                         
 000012  SORT FIELDS=COPY                                                       
 000013 /*                                                                      
 000014 //                                                                      
 ****** **************************** Bottom of Data ****************************

Add comment

Subscribe for more goodness!

Do you like what I'm writing? Sign up to receive new content straight into your mailbox!