Exist any GDG element?



JES, JES2, JCL utilities, IDCAMS, Compile & Run JCLs, PROCs etc...

Exist any GDG element?

Postby tibro1977 » Fri Jun 26, 2020 7:44 pm

Hi, i like to check if any GDG element exist.

//S010CHK  EXEC PGM=IDCAMS
//SYSPRINT DD  SYSOUT=*
//SYSIN    DD  DISP=(OLD,DELETE),DSN=xxx.yyy
//* IS S010CHK found any element in GDG?
//         IF S010CHK.RC = 0
//         THEN
//S010     EXEC PGM=IEBGENER
...
 


what other tools exist for GDG next to IDCAMS?

thx
tibro1977
 
Posts: 1
Joined: Fri Jun 26, 2020 7:35 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Exist any GDG element?

Postby sergeyken » Fri Jun 26, 2020 9:51 pm


//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
...
 
Javas and Pythons come and go, but JCL and SORT stay forever.
User avatar
sergeyken
 
Posts: 438
Joined: Wed Jul 24, 2019 10:12 pm
Has thanked: 7 times
Been thanked: 40 times

Re: Exist any GDG element?

Postby steve-myers » Sun Jun 28, 2020 11:53 pm

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.
steve-myers
Global moderator
 
Posts: 2105
Joined: Thu Jun 03, 2010 6:21 pm
Has thanked: 4 times
Been thanked: 243 times


Return to JCL

 


  • Related topics
    Replies
    Views
    Last post