sergeyken wrote:
//S010CHK EXEC PGM=IDCAMS
//SYSPRINT DD SYSOUT=*
//SYSIN DD *
LISTCAT LEVEL( HIGH.SECOND.THIRD.GDGBASE )
//* IS S010CHK found any element in GDG?
// IF S010CHK.RC = 0 THEN
//S010 EXEC PGM=IEBGENER
...
When I first read this post I asked myself will this produce RC 0 if the index exists and is empty? I decided I had to find out! So I prepared and ran this JCL --
//A EXEC PGM=IDCAMS
//SYSPRINT DD SYSOUT=*
//SYSIN DD *
DEFINE GENERATIONDATAGROUP(NAME(XXXXXX.TESTGDG.INDEX) +
LIMIT(4) )
//B EXEC PGM=IDCAMS
//SYSPRINT DD SYSOUT=*
//SYSIN DD *
LISTCAT ALL ENTRIES(XXXXXX.TESTGDG.INDEX)
//C EXEC PGM=IDCAMS
//SYSPRINT DD SYSOUT=*
//SYSIN DD *
LISTCAT ALL LEVEL(XXXXXX.TESTGDG.INDEX)
//D EXEC PGM=IEBGENER
//SYSPRINT DD SYSOUT=*
//SYSUT1 DD DISP=SHR,DSN=XXXXXX.YH.ASM
//SYSUT2 DD DISP=(,CATLG),UNIT=SYSADA,SPACE=(CYL,(1,1)),
// DSN=XXXXXX.TESTGDG.INDEX(+1)
//SYSIN DD DUMMY
//E EXEC PGM=IDCAMS
//SYSPRINT DD SYSOUT=*
//SYSIN DD *
LISTCAT ALL LEVEL(XXXXXX.TESTGDG.INDEX)
//F EXEC PGM=IEFBR14
//GDG DD DISP=(OLD,DELETE),DSN=XXXXXX.TESTGDG.INDEX(+1)
//G EXEC PGM=IDCAMS
//SYSPRINT DD SYSOUT=*
//SYSIN DD *
DELETE XXXXXX.TESTGDG.INDEX
with, of course, my userid in place of XXXXXX.
The return code for step C (LISTCAT when the index exists but is empty) was 4; the return code for step E (the index exists and is not empty) was 0.
So I can attest sergeyken's idea will work.