All datasets within GDG share same name except the last qualifier which is made of generation number and version number
Generation number is automatically assigned by Operating System
Syntax:- GaaaaVxx
Where, aaaa - absolute generation number, 0001 to 9999 xx - version number, 00 to 99
Datasets within GDG can be referenced by its relative generation number.
GDGBASENAME(0) references current generation
GDGBASENAME(-1) refers to generation just before the current generation
GDGBASENAME(+1)refers to the next generation data set just after the current one
It can also be referenced by actual name of generation dataset for example:- ‘PAYROLL.SALARY.MONTHLY.G0001V00’
Generations are updated only at the end of the job, meaning:-
JOB STEP1 creates one generation, code it as GDGBASENAME(+1)
JOB STEP2 creates one more generation, then you have to code it as GDGBASENAME(+2) because the (+1) is not yet promoted to current generation.
For any executing job the current generation remains same until it ends. So in above case GDGBASENAME(+2) will get promoted to current generation only after execution of job