What is GDG and its Usage in Mainframes

What is a GDG and How its used in JCL

In Mainframe Programming, Generation Data Group is known as GDG which is multiple generations of the same file base. So if there is a GDG base(consider like a parent file) with a name ABC then its generations(children of the parent file ABC) will be ABC.G01, ABC.G02 and so on. When you are defining the GDG Base, you will be giving instructions on how many generations are needed.

What is GDG in Mainframes
Photo by olia danilevich on Pexels.com

Referring GDG in JCL

The current generation is referred with a suffix of 0 which is like ABC(0), the previous generation will be referred as ABC(-1) and the next generation as ABC(+1).

Generations are defined at the end of the job or JCL execution. It means, if the first step creates one generation, code it as ABC(+1) and if the second step creates another generation, then it SHOULD be coded as ABC(+2) as the (+1) version is not yet promoted to current version. Similarly to refer the GDG created in the second step, refer it by ABC(+2).

GDG datasets can be also referenced with their generation number like ‘ABC.G001V00’ which is an actual filename. Referring it as (0) and (-1) are relative references.

Advantages of using GDG

  • GDG datasets are referred in the JCL using GDG base and a relative number. So the same JCL can be used many times without changing the dataset name and this is the biggest advantage of GDG.
  • GDG Base has pointers to all its generations. So reading the GDG base in a JCL without specifying the generation will read all generations created under the base. If flat files are used instead of GDG, then a manual concatenation of datasets to be done in the JCL.

How to create a GDG using IDCAMS

GDG Base is created using the utility called IDCAMS. Below are the parameters or PARMs given while creating the GDG

ParameterPurpose
NAMEGDG base Name
LIMITThe maximum number of GDG versions you needed. S value can range from 1 – 256
EMPTY/NOEMPTYThis Parm defines what needs to be done if the generation is exceeded than specified limit. EMPTY keeps the most recent generation. NOEMPTY keeps the LIMIT number of newest generation.
SCRATCH/ NOSCRATCHSCRATCH option forces to un-catalogue and deletes the versions that are not kept. NOSCRATCH option does un-cataloguing without deleting it physically from the volume.
OWNEROwner of the GDG.
FOR DAYS (n) / TO (DATE)Expiry date till when the dataset has to be preserved.
PARMs used for GDG base creation

Model dataset has to be defined after or along with the creation of base. Once model DCB is defined, then during the allocation or creation of the generations, we don’t need to code DCB parameter. There is an option to override this set DCB parameter by coding new parameter while creating the GDG version. So two GDG version can exist in two different file formats.

Sample JCL to create GDG

Below is a sample JCL to create a GDG base using IDCAMS and MODEL DCB parms.

//GDG         EXEC PGM=IDCAMS

//SYSPRINT DD   SYSOUT=*

//MODEL    DD   DSNAME=TEST.SAMPLE.MASTER,DISP=(,KEEP),

//             UNIT=SYSDA,VOL=SER=XXX800,SPACE=(CYL,(0)),

//             DCB=(DSORG=PS,RECFM=FB,LRECL=400)

//SYSIN    DD   *

 DEFINE GDG ( NAME(TEST1.SAMPLE.MASTER)  –

              LIMIT(5)                   –

              NOEMPTY                    –

              SCRATCH )

/*

GDG Interview Questions

Here are some top interview questions related to GDG (Generation Data Group) in JCL (Job Control Language):

  • What is a GDG in JCL? Answer: A GDG, or Generation Data Group, is a dataset organization technique used in JCL on mainframe systems. It allows for the creation and management of multiple versions of the same dataset.
  • How is a GDG defined in JCL? Answer: A GDG is defined using the DD statement with the DSN (Dataset Name) parameter. The dataset name is followed by a generation number enclosed in parentheses, such as DSN=MY.GDG(0).
  • How is a new generation created in a GDG? Answer: A new generation in a GDG is created by allocating a new dataset using the GDG base name and specifying “+1” as the generation number, such as DSN=MY.GDG(+1).
  • How do you refer to the most recent generation of a GDG in JCL? Answer: The most recent generation of a GDG can be referred to using the “+0” notation, such as DSN=MY.GDG(+0).
  • Can you delete a specific generation from a GDG? Answer: No, you cannot delete a specific generation from a GDG directly. GDG generations are managed automatically by the system, and older generations are typically retained while new generations are added.
  • How can you specify the number of generations to be retained in a GDG? Answer: The number of generations to be retained in a GDG can be specified using the MAXGEN parameter in the GDG base definition. It determines the maximum number of generations that can be retained.
  • What happens when the maximum number of generations is reached in a GDG? Answer: When the maximum number of generations is reached, the oldest generation is automatically deleted to make room for the new generation. The remaining generations are shifted down, and the new generation is added at the highest generation number.
  • Can you specify a disposition for a GDG in JCL? Answer: Yes, you can specify a disposition for a GDG in JCL using the DISP parameter in the DD statement. It allows you to specify whether the GDG is to be kept, deleted, or retained until the job or step completes.
  • How can you retrieve a specific generation from a GDG in JCL? Answer: To retrieve a specific generation from a GDG in JCL, you can specify the desired generation number in the DD statement, such as DSN=MY.GDG(3) to reference the third generation.
  • How do you list all the generations in a GDG? Answer: You can list all the generations in a GDG using the IDCAMS utility with the LISTCAT command. By specifying the GDG base name, it will display information about all the generations associated with that GDG.

These questions cover the basics of GDGs in JCL. It’s important to study further and gain hands-on experience to have a comprehensive understanding of GDGs and their usage in mainframe environments.

Leave a Comment