Joined: 13 Jul 2007 Posts: 34 Topics: 10 Location: Los Angeles
Posted: Mon Jul 16, 2007 4:18 am Post subject: Checking the Existance of a File Through a JCL
Hi,
I am working on a project where I need to create a JCL which comprises of:
Scenario:
Start of Job
Step1. Process File1 (assuming File1 is on Mainframes)
Step2. Process File2 (assuming File2 is on Mainframes)
Step3. Check whether File3 is available on Mainframe or not.
Only if File3 is available on Mainframes, Step4 & Step5 should be run. Else, only Step5 should be run.
Step4. Process File3
Step5. Few analysis
End of Job
Could you please suggest me how to handle this situation? My code comprises of SAS programming. I tried using IDCAMS, but it's not working, instead it's throwing JCL ERROR while submitting. Your help is greatly appreciated.
Thanks & Regards,
Bharath. _________________ Regards,
BK
***** " If You Have To Do It, You Might As Well Do It Right.....If It Is Worth Doing At All, It's Worth Doing It Right !!! " *****
Joined: 13 Jul 2007 Posts: 34 Topics: 10 Location: Los Angeles
Posted: Mon Jul 16, 2007 4:31 am Post subject:
Thank you for your advise. I did it already and tried all the ways in my mainframe environment. All the examples are told on pure guesses with no practical research, I believe. When I actually try them, it's giving a JCLERROR all the times, no matter which example I try.
Joined: 26 Nov 2002 Posts: 12369 Topics: 75 Location: San Jose
Posted: Mon Jul 16, 2007 6:36 am Post subject:
Bharath.AK,
Use this JCL to set the return code and do a condition code check for execueting the step 4 & step 5
Code:
//************************************************
//* SETS RC=00 IF DATASET HAS ATLEAST 1 RECORD *
//* SETS RC=04 IF DATASET IS EMPTY *
//* SETS RC=12 IF DATASET IS NOT FOUND *
//************************************************
//STEP0100 EXEC PGM=IDCAMS
//SYSPRINT DD SYSOUT=*
//SYSIN DD *
PRINT IDS('your file 3 to be checked') COUNT(1)
/*
Joined: 13 Jul 2007 Posts: 34 Topics: 10 Location: Los Angeles
Posted: Mon Jul 16, 2007 7:37 am Post subject:
Thank you for the reply Kolusu!
I'd tried giving the condition codes either using COND and IF-THEN as well. But in the STEP001 it self the JCL is ABENDing, without going further to STEP002 to check the condition. Throwing JCLERROR at STEP001 itself. Logically it should work, but it;s not working. Failing at STEP001 itself. If the control goes to STEP002, then we can check the COND right. The flow is not going beyond STEP001.
Please advice.
Joined: 02 May 2007 Posts: 202 Topics: 0 Location: Viginia, USA
Posted: Mon Jul 16, 2007 7:47 am Post subject:
Bharath.AK wrote:
Thank you for the reply Kolusu!
I'd tried giving the condition codes either using COND and IF-THEN as well. But in the STEP001 it self the JCL is ABENDing, without going further to STEP002 to check the condition. Throwing JCLERROR at STEP001 itself. Logically it should work, but it;s not working. Failing at STEP001 itself. If the control goes to STEP002, then we can check the COND right. The flow is not going beyond STEP001.
Please advice.
Joined: 13 Jul 2007 Posts: 34 Topics: 10 Location: Los Angeles
Posted: Mon Jul 16, 2007 7:59 am Post subject:
Hello!
CraigG!
In my code below, STEP002 is getting executed though FILE3 is not available on the mainframes (by checking the condition codes). But the thing is the MAXCC of the job I'm getting is 12, which looks unexpected to the people who actually see the RC of that job. Can we anyway get the MAXCC of a job as normal, even though the file doesn't exist on the mainframe?
Joined: 26 Nov 2002 Posts: 12369 Topics: 75 Location: San Jose
Posted: Mon Jul 16, 2007 8:27 am Post subject:
Quote:
In my code below, STEP002 is getting executed though FILE3 is not available on the mainframes (by checking the condition codes).
Bharath.AK,
You are requesting Step002 to run if the step001 return code is 12. And in case the file is not the return code is indeed 12 and it is execueting the step002. what do you expect?
Quote:
But the thing is the MAXCC of the job I'm getting is 12, which looks unexpected to the people who actually see the RC of that job
You can reset the maxcc to a lower code but how do you distinguish between dataset NOT FOUND vs empty dataset?
any way here is a way to set the maxcc for the step to a lower values
Code:
//STEP001 EXEC PGM=IDCAMS
//SYSPRINT DD SYSOUT=*
//SYSIN DD *
PRINT IDS('FILE3') COUNT(1)
IF LASTCC=12 THEN SET MAXCC=4
/*
Joined: 13 Jul 2007 Posts: 34 Topics: 10 Location: Los Angeles
Posted: Tue Jul 17, 2007 4:24 am Post subject:
Hi Kolusu,
Thanks for your feedback. You are right. By your statements:
Quote:
"You are requesting Step002 to run if the step001 return code is 12. And in case the file is not the return code is indeed 12 and it is execueting the step002. what do you expect? "
Here, there are several successor jobs which are scheduled to run automatically depending upon the successful completion of the current job. That is why I am looking for MAXCC=4 or 0.
Quote:
"You can reset the maxcc to a lower code but how do you distinguish between dataset NOT FOUND vs empty dataset? "
I don't need to explicitly know whether the file is available or not on the mainframes. I only need, if it exists, then process it. Else process further steps.
Thaks for your support in clearing my doubts. I will work on the same to make it feasible. _________________ Regards,
BK
***** " If You Have To Do It, You Might As Well Do It Right.....If It Is Worth Doing At All, It's Worth Doing It Right !!! " *****
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum