Page 1 of 1

Check for empty data set within JCL?

Posted: Mon Oct 13, 2014 5:06 pm
by Rahul Chandra
Hi!

I want to execute a step only if a particular data set is empty. Can anybody help me to identify empty data set within JCL or guide to do this?

Thanks and Regards

Re: Check for empty data set within JCL?

Posted: Tue Oct 14, 2014 9:11 am
by Anuj Dhawan
You can try this:

Code: Select all

//STEP01 EXEC PGM=ICETOOL 
//IN DD DSN=...your.file,DISP=SHR
//TOOLMSG DD SYSOUT=* 
//DFSMSG DD SYSOUT=* 
//TOOLIN DD DATA 
COUNT FROM(IN) EMPTY 
/* 
//* 
// IF (STEP01.RC) = 0 THEN 
//STEP02 EXEC PGM=whennotempty 
// ELSE 
//STEP03 EXEC PGM=whenempty 
//*
If you want to use IDCAMS for STEP01, you can use any of these:

Code: Select all

//INDD DD DSN=...file.to.be.checked,DISP=SHR 
//OUTDD DD DSN=OUTPUT FILE,DISP=SHR 
//SYSIN DD * 
REPRO INFILE(INDD) OUTFILE(OUTDD) COUNT(1) 
/* 
If the file is EMPTY, you'll get RC=04.

You can also use:

Code: Select all

//STEP0001 EXEC PGM=IDCAMS 
//IN DD DSN=...file.to.be.checked, DISP=SHR
//SYSPRINT DD SYSOUT=* 
//SYSIN DD DATA 
PRINT INFILE(IN) COUNT(1) 
/* 
If the file has a record it'll get RC=0 otherwise RC=4.

Re: Check for empty data set within JCL?

Posted: Tue Dec 02, 2014 3:15 pm
by Rahul Chandra
Thank you so much Anuj. This has helped greatly.

Appreciate your help.

Re: Check for empty data set within JCL?

Posted: Tue Dec 02, 2014 5:17 pm
by Anuj Dhawan
You're welcome! :)