Joined: 26 Apr 2004 Posts: 4650 Location: Raleigh, NC, USA
When you run a LISTCAT against the GDG base you should get back a report of all of the associated generations for that base. The best thing I can think of off-hand would be to then count the number of lines like this:
run listcat from Rexx and either outtrap() the results or allocate all the needed ddnames and run IDCAMS to do the listcat. I'm sure someone can also provide some means of examining the listcat with SORT and count operations using a referback to the SYSPRINT ddname. (personally that seems sort of silly to me, but I guess if you want to have everything in a single job stream with no external Rexx, that might be OK).
I might as well add that you can also run any program that does a catalog search. You can modify 'sys1.samplib(IGGCSIRX)' or use the freeware Rexx REALNAME( your.gdg(0) ) function (with site approval, of course).
Rexx is for "application programmers" so I don't know why there would be "no rexx" (thought that has been discussed to death here already and my blood pressure will cause my head to explode if we go through that again).
If it is a "no rexx" situation, you are stuck with SORT or writing COBOL, assembler, PL/I, basic, apl, perl, java, awk scripts, shell scripts, algol, snobol, clist, or anything else your "no rexx" shop will allow "application programmers" to use.
And before anyone starts talking about z/OS programmers who won't learn Rexx in hopes of seeing a video of my head exploding on YouTube, let me tell you I don't have a camera.
As I'm in such a good mood, I'll do your work for you. Save you throwing your toys out of the pram when a REXX solution was offered but was unacceptable. But of course, had you have stated from the outset what was and was not acceptable then one of the senior members could have used his efforts for a more deserving post. Neither did you mention the implications of a dummy +1 GDS. We are IT people not psychics !!!
The solution is hardly rocket science, and has been discussed various times on the forum. There is a search button you know. Have you tried using it ?
The code above will list the GDG base and any associated generations. The sort step picks up if any generations exist, by testing various places to find generally accepted GDS syntax and, if generations do exist will give RC=0. If no generations exist then it will give RC=4.
You will probably have to adjust the positions for where the test fields are located on your own, but if that's too much for you, please let one of us know and we'll do it for you.
Oh, I suppose I'd better add that you then run your real sort conditionally based on the RC from these steps, just in case you got confused with what to do next.