Check for empty data set within JCL?

JES2/3, JCL, utilities.
Post Reply
Rahul Chandra
New Member
Posts: 6
Joined: Fri Aug 01, 2014 10:12 am

Check for empty data set within JCL?

Post 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
User avatar
Anuj Dhawan
Founder
Posts: 2802
Joined: Sun Apr 21, 2013 7:40 pm
Location: Mumbai, India
Contact:
India

Re: Check for empty data set within JCL?

Post 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.
Thanks,
Anuj

Disclaimer: My comments on this website are my own and do not represent the opinions or suggestions of any other person or business entity, in any way.
Rahul Chandra
New Member
Posts: 6
Joined: Fri Aug 01, 2014 10:12 am

Re: Check for empty data set within JCL?

Post by Rahul Chandra »

Thank you so much Anuj. This has helped greatly.

Appreciate your help.
User avatar
Anuj Dhawan
Founder
Posts: 2802
Joined: Sun Apr 21, 2013 7:40 pm
Location: Mumbai, India
Contact:
India

Re: Check for empty data set within JCL?

Post by Anuj Dhawan »

You're welcome! :)
Thanks,
Anuj

Disclaimer: My comments on this website are my own and do not represent the opinions or suggestions of any other person or business entity, in any way.
Post Reply

Create an account or sign in to join the discussion

You need to be a member in order to post a reply

Create an account

Not a member? register to join our community
Members can start their own topics & subscribe to topics
It’s free and only takes a minute

Register

Sign in

Return to “JCL - Job Control Language.”