One way that would seem to work would be to first, before the new generation is created, to run IDCAMS LISTCAT against the GDG base and list all of the existing generations at that moment in time. Then, run the rest of the job. At the end, run IDCAMS LISTCAT again to create a new list. Remove the duplicates from the combined lists, and what is left should be the unique new generation. Combine that with the record count and you should be all set.
If you can execute a REXX program from that job, then the taks will be very simple.
You can write a rexx program to use the listds command witht the GDG base name. It would display all the GDG versions in the ascending order. You can outtrap these lines and get the first occurence of the GDG name. That is the latest version. Please find a sample code below.
X = Outtrap('DsnRes.','*')
Address TSO "Listds '"dsname"' Level"
Do i = 1 to DsnRes.0 /* For stripping the spaces */
DsnRes.i = Strip(Word(DsnRes.i,1))
Do i = 1 to DsnRes.0 /* Getting only the GDGs from the DsnRes */
Idx=index(DsnRes.i,'XXX.YYY.') /* XXX.YYY is the higher level qualifiers of GDG ****/
if Idx=1 then do
say 'GDG ' j 'is ' gdg.j
j = j - 1
version = gdg.j /* version contains the latest GDG */
If j < 1 Then Do
Say "There are no GDGs!"
For getting the count of the records, you can open the GDG and just STEM the records into an array. Now the array size will give you the record count.