JCL GDG Life Cycle: Create, Model, Generate, Delete, Alter

In this article, you will learn the complete life cycle of a JCL GDG Create, Delete, Alter (Generation Data Group), explained step by step.

6 Top GDG Prime Points

  1. Create GDG
  2. GDG Template
  3. Create first GDG
  4. Create new generation GDG
  5. Delete GDG

1.Create a GDG File

Create a JCL GDG file. This JCL calling IDCAMS will do it. In this example LIMIT(15) is the number of generations you wish to create and keep. Of course, change the GDG file name to your requirements:

//STEP1 EXEC PGM=IDCAMS  
//SYSPRINT DD SYSOUT=*  
//SYSIN DD *   
DEFINE GDG(NAME(STEWART.APPLY.LOG.GDGROUP1) -   
LIMIT(15) -   
NOEMPTY -   
SCRATCH)
  /*

2. Create a GDG Model

Create a model or template for the individual generations of data sets. Here the default DCB attributes for the Apply or Capture log were used. Note that the space is rather small (5 tracks) in this example so you might want to increase it.

//STEP020 EXEC PGM=IEFBR14 
//GDGMODEL DD DSN=STEWART.APPLY.LOG.GDMODEL1, 
// DISP=(NEW,KEEP,DELETE), 
// UNIT=SYSDA, 
// SPACE=(TRK,5), 
// DCB=(LRECL=1024,RECFM=VB,BLKSIZE=6144,DSORG=PS)

Hard skills get you the interview, soft skills get you the job.

Anonymous

3. Generate GDG

As a test, you can create your first generation of data sets by running this JCL example. Each time you run this step a new generation of data set will be created in your group.

//STEP010 EXEC PGM=IEBGENER 
//SYSPRINT DD SYSOUT=* 
//SYSIN DD DUMMY 
//SYSUT1 DD *  
TEST DATA LINE 1  TEST DATA LINE 2 
/* 
//SYSUT2 DD DSN=STEWART.APPLY.LOG.GDGROUP1(+1),
// DISP=(NEW,CATLG,DELETE),
// SPACE=(TRK,5), 
// DCB=STEWART.APPLY.LOG.GDMODEL1

After you have created several generations of log files an ISPF 3.4 display of your GDG would look like this:

STEWART.APPLY.LOG.GDGROUP1
STEWART.APPLY.LOG.GDGROUP1.G0003V00
STEWART.APPLY.LOG.GDGROUP1.G0004V00
STEWART.APPLY.LOG.GDGROUP1.G0005V00
.
.
.
STEWART.APPLY.LOG.GDMODEL1

The ISPF 3.4 screen header also tells you how many generations of datasets you have.

For example, Data Sets Matching STEWART.APPLY.LOG.GDGROUP1.G* Row 1 of 15. There are 15 generations of the dataset.

4. New Generation GDG

Because the Apply or Capture log file is not referenced by a DD statement you must use IEBGENER to copy your app.log or cap.log file to the GDG. Place this step ahead of your Apply or Capture JCL.

This step creates a new generation of data in your group. Consider using the LOGREUSE=N parm when you start Capture or Apply so that each generation of the log is unique to the specific instance when Capture or Apply was run.

//COPYLOG EXEC PGM=IEBGENER 
//SYSPRINT DD SYSOUT=*
//SYSUT1 DD DSN=STEWART.DSN9.STEVE1.APP.LOG,
// DISP=SHR
//SYSUT2 DD DSN=STEWART.APPLY.LOG.GDGROUP1(+1),
// DISP=(NEW,CATLG,DELETE),
// SPACE=(TRK,5),
// DCB=STEWART.APPLY.LOG.GDMODEL1
//SYSIN DD DUMMY //SYSOUT DD SYSOUT=*
//SYSUDUMP DD SYSOUT=*

5. Delete GDG

If you need to delete your GDG, delete the individual data sets (G0003V00, G0004V00, etc.) and then run this IDCAM job to delete the GDG.

//STEP010 EXEC PGM=IDCAMS 
//SYSPRINT DD SYSOUT=*
//SYSIN DD * DELETE (STEWART.APPLY.LOG.GDGROUP1) GDG FORCE
/*

Finally, 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 GDG name in the ALTER statement that you created from Step 1.

//STEP010 EXEC PGM=IDCAMS 
//SYSPRINT DD SYSOUT=*
//SYSIN DD * ALTER STEWART.APPLY.LOG.GDGROUP1 LIMIT(50)
/*

The maximum value for LIMIT is 255.

Ref:IBM

Frequently Asked Questions

1. What is a JCL GDG and what is it used for?

A JCL GDG (Generation Data Group) is a collection of historically related datasets organized under a single base name on z/OS mainframe systems. Each time a new generation is created, it receives a unique generation number (such as G0001V00, G0002V00, etc.). JCL GDGs are commonly used to retain and manage successive versions of data files — for example, application logs, batch output, or archive files — while automatically controlling how many generations are kept.

2. How do you create a JCL GDG base?

You create a JCL GDG base by running an IDCAMS job with the DEFINE GDG statement. You specify the base name, the LIMIT (maximum number of generations to retain), and options such as NOEMPTY and SCRATCH. For example: DEFINE GDG(NAME(MY.GDG.BASE) LIMIT(15) NOEMPTY SCRATCH). This registers the GDG base in the catalog but does not yet create any generation datasets.

3. What does the LIMIT parameter control in a JCL GDG?

The LIMIT parameter in a JCL GDG definition sets the maximum number of generation datasets that can exist in the group at one time. For example, LIMIT(15) means up to 15 generations are kept. When a new generation is added beyond the limit, the oldest generation is automatically removed (if SCRATCH is specified). The maximum value for LIMIT is 255.

4. How do you delete a JCL GDG?

To delete a JCL GDG, first delete all individual generation datasets (e.g., G0001V00, G0002V00) using standard dataset deletion methods. Then run an IDCAMS job with the DELETE statement and the GDG keyword and FORCE option, for example: DELETE (MY.GDG.BASE) GDG FORCE. The FORCE option ensures the GDG base entry is removed from the catalog even if generation datasets still exist.

5. How do you alter the generation limit of a JCL GDG?

You can alter the generation limit of an existing JCL GDG by running an IDCAMS job with the ALTER statement. Specify the GDG base name and the new LIMIT value — for example: ALTER MY.GDG.BASE LIMIT(50). This changes the maximum number of generations retained without affecting existing generation datasets. The maximum allowable LIMIT value is 255.

How to Manage a GDG

  1. Define the JCL GDG base.

    Run an IDCAMS job using the DEFINE GDG statement. Specify the base name, the LIMIT (maximum number of generations, up to 255), and options such as NOEMPTY and SCRATCH to control behavior when the limit is reached.

  2. Create a GDG model dataset.

    Use IEFBR14 to allocate a model (template) dataset that defines the default DCB attributes — record format, logical record length, block size, and space — for all generation datasets in the JCL GDG group.

  3. Create the first generation.

    Run a JCL job (for example, using IEBGENER) that writes data to the GDG base name with a relative generation number of (+1). This creates the first generation dataset (e.g., G0001V00) and catalogs it automatically.

  4. Create new generations.

    Each subsequent run of your JCL job using (+1) in the dataset name creates the next generation of data. The JCL GDG automatically increments the generation number. Use the LOGREUSE=N parameter where applicable to ensure each generation captures a unique instance of your data.

  5. Delete individual generations or the entire JCL GDG.

    To remove specific generation datasets, delete them individually by name. To remove the entire JCL GDG group, delete all generation datasets first, then run IDCAMS with DELETE (base-name) GDG FORCE to remove the base catalog entry.

  6. Delete individual generations or the entire JCL GDG.

    If you need to retain more generations, run an IDCAMS job with the ALTER statement and specify the new LIMIT value (e.g., LIMIT(50)). This updates the catalog definition

Discover more from Srinimf

Subscribe now to keep reading and get access to the full archive.

Continue reading