MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Checking the Existance of a File Through a JCL

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Job Control Language(JCL)
View previous topic :: View next topic  
Author Message
Bharath.AK
Beginner


Joined: 13 Jul 2007
Posts: 34
Topics: 10
Location: Los Angeles

PostPosted: Mon Jul 16, 2007 4:18 am    Post subject: Checking the Existance of a File Through a JCL Reply with quote

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 !!! " *****
Back to top
View user's profile Send private message
Sreejith
Intermediate


Joined: 02 Dec 2002
Posts: 155
Topics: 25
Location: N.Ireland

PostPosted: Mon Jul 16, 2007 4:28 am    Post subject: Reply with quote

there are plenty of example in this site. A search shows many
Back to top
View user's profile Send private message Send e-mail Yahoo Messenger
Bharath.AK
Beginner


Joined: 13 Jul 2007
Posts: 34
Topics: 10
Location: Los Angeles

PostPosted: Mon Jul 16, 2007 4:31 am    Post subject: Reply with quote

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.

Anyways, thanks again!
Back to top
View user's profile Send private message
Sreejith
Intermediate


Joined: 02 Dec 2002
Posts: 155
Topics: 25
Location: N.Ireland

PostPosted: Mon Jul 16, 2007 4:37 am    Post subject: Reply with quote

Oops!! Sorry looks like I searched on a different site..


Saw this

Code:


//GENCMD   EXEC PGM=IEBGENER
//SYSPRINT DD SYSOUT=*
//* SYSUT1 - PROVIDE THE DATASET WITH DSNAMES HERE  --------------- *//
//*          FOR TESTING PURPOSES USE INSTREAM DATA --------------- *//
//SYSUT1   DD *
DSNAME1
DSNAME2
//SYSUT2   DD DSN=&&TEMP,DISP=(NEW,PASS,DELETE),
//            DCB=(LRECL=80,BLKSIZE=0,RECFM=FB,DSORG=PS),
//            SPACE=(TRK,(1,1))
//SYSIN    DD *
  GENERATE MAXFLDS=99,MAXLITS=99
  RECORD       FIELD=(9,'  LISTDS ',,1),
               FIELD=(63,1,,10)
/*
//* --------------------------------------------------------------- *//
//SHOWDCB  EXEC PGM=IKJEFT01
//SYSPRINT DD SYSOUT=*
//* SYSTSPRT - PROVIDE THE OUTPUT DATASET HERE   ------------------ *//
//*            FOR TESTING PURPOSES USE SYSOUT=* ------------------ *//
//SYSTSPRT DD DSN=OUTPUT.DATASET,DISP=(NEW,CATLG,DELETE),
//            DCB=(LRECL=80,BLKSIZE=0,RECFM=FB,DSORG=PS),
//            SPACE=(TRK,(1,1))
//SYSTSIN  DD *
  PROFILE NOPREFIX
//         DD DISP=(OLD,DELETE,DELETE),DSN=&&TEMP
//

Back to top
View user's profile Send private message Send e-mail Yahoo Messenger
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12369
Topics: 75
Location: San Jose

PostPosted: Mon Jul 16, 2007 6:36 am    Post subject: Reply with quote

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)
/*                                   


Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12369
Topics: 75
Location: San Jose

PostPosted: Mon Jul 16, 2007 6:39 am    Post subject: Reply with quote

Sreejith,

How do you set the return code with the job you have shown?

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Bharath.AK
Beginner


Joined: 13 Jul 2007
Posts: 34
Topics: 10
Location: Los Angeles

PostPosted: Mon Jul 16, 2007 7:37 am    Post subject: Reply with quote

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.

Quote:

//STEP001 EXEC PGM=IDCAMS
//SYSPRINT DD SYSOUT=*
//SYSIN DD *
PRINT IDS('FILE3') COUNT(1)
/*
// IF (STEP016.RC EQ 12) THEN
//STEP002 EXEC PGM=SORT

_________________
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 !!! " *****
Back to top
View user's profile Send private message
CraigG
Intermediate


Joined: 02 May 2007
Posts: 202
Topics: 0
Location: Viginia, USA

PostPosted: Mon Jul 16, 2007 7:47 am    Post subject: Reply with quote

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.

Quote:

//STEP001 EXEC PGM=IDCAMS
//SYSPRINT DD SYSOUT=*
//SYSIN DD *
PRINT IDS('FILE3') COUNT(1)
/*
// IF (STEP016.RC EQ 12) THEN
//STEP002 EXEC PGM=SORT

Do you think you could share the sysout and jes/jcl logs with us so we don't have to guess at what the problem is?
Back to top
View user's profile Send private message
Bharath.AK
Beginner


Joined: 13 Jul 2007
Posts: 34
Topics: 10
Location: Los Angeles

PostPosted: Mon Jul 16, 2007 7:59 am    Post subject: Reply with quote

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?

Quote:

//STEP001 EXEC PGM=IDCAMS
//SYSPRINT DD SYSOUT=*
//SYSIN DD *
PRINT IDS('FILE3') COUNT(1)
/*
// IF (STEP001.RC EQ 12) THEN
//STEP002 EXEC PGM=SORT

_________________
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 !!! " *****
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12369
Topics: 75
Location: San Jose

PostPosted: Mon Jul 16, 2007 8:27 am    Post subject: Reply with quote

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
/*


Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Bharath.AK
Beginner


Joined: 13 Jul 2007
Posts: 34
Topics: 10
Location: Los Angeles

PostPosted: Tue Jul 17, 2007 4:24 am    Post subject: Reply with quote

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 !!! " *****
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Job Control Language(JCL) All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
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


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group