Mainframes 360
The one stop destination for System Z professionals

Saturday, July 11, 2009

IBM Utilities Tutorial – 04 : Generation Data Group - GDG

References :
- Drona’s Tutorial – How to create and Delete GDGs
- Simotime – Everything about Generation Data Groups

Q. What is a GDG(Generation Data Group)?
Suppose we have stored a large amount of data of all credit-card holders in a Sequential Dataset. The Credit-card holders dataset, stores their name, billing address, total credit limit, available balance, minimum amount due etc. The data in the Credit-card holder file has to be updated every to reflect the purchases and payments made by the card-holder. So, periodically, every month, a Batch JOB is run to update the Credit Card Accounts dataset.

Suppose, the Credit Card Accounts have been updated till the month of July. But, what if we wanted to see the status of Credit Card Accounts, for a previous month say January, this wouldn’t be possible, since, we have lost the old data. In other words, we need to preserve the past historical data. What if the customer wanted a report which shows him, his Bank Account Statement of the last 6 months?

Thus, we need to store older/previous versions of the Credit Card Accounts dataset. When we want to maintain not only the current version of the file, but also previous versions, this calls for Generation Data Group(GDG).

A Generation Data Group(GDG) is a group of datasets, each having a father-son relationship. Every dataset/generation in the group is given a unique Generation Number. Suppose the name of the GDG is BANK.CREDITCARDS.ACCOUNT. Then, the first dataset which is created in this GDG, will have a generation number G0001V00. If we update this dataset, to create the next generation, the generation number becomes G0002V00. Again, for the next generation, the generation number will be G0003V00, and so on...

How to access a particular generation? There are two ways to do this. First, the name of a dataset inside a GDG is always => Name-of-GDG.generation-number. So, the generation G0002V00 can be accessed directly as BANK.CREDITCARDS.ACCOUNT.G0002V00. The other way, we can access generations is by using relative referencing. Suppose the current/latest generation in the GDG is G0003V00. The current generation is called Generation 0. So, the generation G0003V00 can be accessed as BANK.CREDITCARDS.ACCOUNT(0). To access the previous generations/ancestors of G0003V00, that is G0002V00, we must subtract (-1) from the generation number. So, the generation G0002V00 can be accessed as BANK.CREDITCARDS.ACCOUNT(-1). The successors of G0003V00, such as G0004V00 can be accessed as BANK.CREDITCARDS.ACCOUNT(+1). Thus, we can access datasets within a GDG in 2 ways : 1) Absolute dataset name 2) Relative reference
Q. What is a GDG Base or GDG Index?
To a build a GDG, you first need to build a GDG Base entry/GDG Index. This is nothing but an entry in the VTOC(Volume Table of Contents), a catalog which keeps track of all datasets on a volume.

To build a GDG Base, we use the IBM Supplied IDCAMS Utility program. The following JCL shows how :

The DEFINE GDG Control card is required to define a GDG Base.

– Specifies the name of the GDG. Here, the name of the GDG is HERC04.BANK.ACCOUNTS.

– Specifies how many generation will be stored in the GDG. Here, we have kept limit as 3. This means, a maximum of 3 generations will be stored in the GDG. You can specify any no. from 1 – 255.

NOEMPTY – This specifies, what action is to be taken when the GDG becomes full. NOEMPTY means, that when GDG becomes full(contains 3 generations), and another generation(4th generation) is added, the oldest generation will be deleted. EMPTY means that, when GDG is full, and 4th generation is added, all the old generations should be deleted, that the GDG should be made empty/flushed.

SCRATCH – This specifies, what happens to the Data Control Block of a generation when it it deleted. Every generation’s DCB is stored in VTOC. SCRATCH implies that when a generation is uncataloged, its DCB from the VTOC, should also be deleted/scratched(erased).
Q. What is GDG Model? Show me the JCL to create a GDG Model.
Now, that you know, how to create a GDG Base entry, the second thing before we can get started with storing generations in the GDG, is we have to create a GDG Model.

A GDG Model is a description of the DCB of all the datasets(generations) within the GDG. This means, all the generations within the GDG follow, the same record format, the same record length, the same block size etc. In other words, GDG Model dataset acts as a model/blueprint, a generalised template for all the generations that you will create and add to the GDG.

To create a GDG Model, we simply need to create an empty dataset, no space allocation, and bearing the DCB of the generations, you want to create. We can do this with the help of IEFBR14.

Q. Alright, so we’ve created GDG Base, GDG Model. Now, How about creating a Generation Dataset (GDS) inside the GDG?
Yup.. That’s what we’ll do now, without beating around the bush much, let’s come straight to the point. How do you create a GDS(Generation Dataset) inside a GDG?

To create a new Generation Dataset, we need to add (+1) to the GDG name, so as to indicate this is a new generation. That’s it. Rest all remains the same, just like we create an ordinary dataset.

Note : It is must to code UNIT and DDN Parameters on all new Generation Datasets.

So, here’s the JCL that adds a new generation to the above GDG HERC04.BANK.ACCOUNTS.

RECORD-1 100001  
 RECORD-2 100002  
//   SPACE=(TRK,5),

Note : Only after this Batch JOB/JCL is complete, this GDS will become the current generation 0. If you are writing the code to access the GDS within the same Batch Job, it will still be referred to as Generation +1.

To many people who are thrown to work at a mainframe computer on their first job, they feel lost. Mainframe people seem to speak a completely different language and that doesn't make life easy. What's more, the books and manuals are incredibly hard to comprehend.

"What on earth is a Mainframe?" is an absolute beginner's guide to mainframe computers. We'll introduce you to the hardware and peripherals. We'll talk about the operating system, the software installed on a mainframe. We'll also talk about the different people who work on a mainframe. In a nutshell, we'll de-mystify the mainframe.

Readers based in India, can buy the e-book for Rs. 50 only or the print book. International readers based in the US and other countries can click here to purchase the e-book.