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
Check for empty data set within JCL?
-
- New Member
- Posts: 6
- Joined: Fri Aug 01, 2014 10:12 am
- Anuj Dhawan
- Founder
- Posts: 2802
- Joined: Sun Apr 21, 2013 7:40 pm
- Location: Mumbai, India
- Contact:
Re: Check for empty data set within JCL?
You can try this:
If you want to use IDCAMS for STEP01, you can use any of these:
If the file is EMPTY, you'll get RC=04.
You can also use:
If the file has a record it'll get RC=0 otherwise RC=4.
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
//*
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)
/*
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)
/*
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.
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.
-
- New Member
- Posts: 6
- Joined: Fri Aug 01, 2014 10:12 am
Re: Check for empty data set within JCL?
Thank you so much Anuj. This has helped greatly.
Appreciate your help.
Appreciate your help.
- Anuj Dhawan
- Founder
- Posts: 2802
- Joined: Sun Apr 21, 2013 7:40 pm
- Location: Mumbai, India
- Contact:
Re: Check for empty data set within JCL?
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.
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.
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