cpuhawg
Active User
Joined: 14 Jun 2006 Posts: 331 Location: Jacksonville, FL
|
|
|
|
A GDG is a dataset, however, a dataset if not necessarily a GDG.
When you create a dataset in a job, you give that dataset a name and you may also give it a retention period or expiration date to specify when the dataset will be deleted from the catalog.
A GDG is a "generation data group". When you define a GDG to the system using the IDCAMS utility, you specify a limit. This limit indicates how many versions of the dataset to keep.
For example:
Code: |
//DEFINE EXEC PGM=IDCAMS
//SYSPRINT DD SYSOUT=*
//SYSIN DD *
DEF GDG (NAME(HLQ.DATASET.NAME.FILE) LIMIT(7) SCRATCH)
ALTER 'HLQ.DATASET.NAME.FILE' LIMIT(4)
DEL 'HLQ.DATASET.NAME.FILE' GDG
/*
|
The 1st example is a DEFINE. You are creating a GDG by the name of HLQ.DATASET.NAME.FILE. The limit is set to 7.
The 2nd example is a ALTER. This would change the limit to 4.
The 3rd example is a DELETE. This would delete the GDG definition on the system.
Once a GDG is defined, you can then start creating GDG datasets. When you run your job to create this dataset, you specify:
//TAPEOA DD DSN=HLQ.DATASET.NAME.FILE(+1),UNIT=SYSDA...etc.
This would create a file called:
HLQ.DATASET.NAME.FILE.G0001V00
The next time you create the dataset it would be called:
HLQ.DATASET.NAME.FILE.G0002V00
The next time:
HLQ.DATASET.NAME.FILE.G0003V00
Each time the version goes up 1.
When you create the 8th version with the limit set to 7. The system will delete the 1st version (G0001V00). That way you always keep 7 versions of the dataset.
If you want to read the last created version of the dataset, You would code:
HLQ.DATASET.NAME.FILE(0)
If you wanted to read the last 5 versions into a sort, you would code:
//SORTIN DD DSN=HLQ.DATASET.NAME.FILE(0),DISP=SHR
// DD DSN=HLQ.DATASET.NAME.FILE(-1)DISP=SHR
// DD DSN=HLQ.DATASET.NAME.FILE(-2),DISP=SHR
// DD DSN=HLQ.DATASET.NAME.FILE(-3),DISP=SHR
// DD DSN=HLQ.DATASET.NAME.FILE(-4),DISP=SHR
Note that the versions are not created until a job ends, so if you write a GDG with:
//TAPEOA DD DSN=HLQ.DATASET.NAME.FILE(+1),UNIT=SYSDA...etc.
and you want to read the GDG in a later step, you must code:
//TAPEIA DD DSN=HLQ.DATASET.NAME.FILE(+1),DISP=SHR
However, if you want to READ it into another job, you must code:
//TAPEIA DD DSN=HLQ.DATASET.NAME.FILE(0),DISP=SHR
Also, you can always reading a specific version by coding:
//TAPEIA DD DSN=HLQ.DATASET.NAME.FILE.G0003V00,DISP=SHR |
|