Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

How to check whether dataset exists or not
Goto page 1, 2  Next
 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> All Other Mainframe Topics
View previous topic :: :: View next topic  
Author Message
ibmmainframesyntel

Active User


Joined: 26 Feb 2007
Posts: 126
Location: Chennai

PostPosted: Mon Feb 26, 2007 7:18 pm    Post subject: How to check whether dataset exists or not
Reply with quote

How to check wether dataset exists or not .

i have to execute my job.

It may contains 3 or two input file.

so, before executing the above step, I have to check wether the dataset exists or not, so that I can override my PROC according to that
either 2 or 3 input file.
Back to top
View user's profile Send private message

superk

Moderator Team Head


Joined: 26 Apr 2004
Posts: 4648
Location: Raleigh, NC, USA

PostPosted: Mon Feb 26, 2007 8:07 pm    Post subject: Re: How to check whether dataset exists or not
Reply with quote

Ask yourself, how would you do this in TSO (TSO, not ISPF) if you needed to? The method would be the same.
Back to top
View user's profile Send private message
ofer71

Global Moderator


Joined: 27 Dec 2005
Posts: 2360
Location: Israel

PostPosted: Mon Feb 26, 2007 9:35 pm    Post subject:
Reply with quote

LISTDSI & SYSDSN are the methods for you.

O.
Back to top
View user's profile Send private message
deepak.vl

New User


Joined: 17 Feb 2007
Posts: 38
Location: Hyderabad

PostPosted: Mon Feb 26, 2007 11:52 pm    Post subject: How to check whether dataset exists or not
Reply with quote

Have a step which tries to read the dataset, for which you want to check whether it exists.
Have 2 steps after this, one to execute if the step 1 fails and other when step 1 is successful.
Control the execution of Steps 2 & 3 by using either a COND or an IF-ELSE.
Something like this...

STEP1 EXEC ..... --> (will try to read the dataset)
STEP2 EXEC ......COND=(0,EQ) --> (this will assume there are 3 datasets)
STEP3 EXEC ......COND=(0,NE) --> (this will assume there are 2 datasets)

Thanks,
Deepak
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Tue Feb 27, 2007 12:00 am    Post subject:
Reply with quote

Hello,

If step1 "tries to read" and the dataset does not exist, there will not be a recurn-code issued - the job will fail with a jcl error with the information that the dataset does not exist.

Please refer back to the post from superk. You need to verify existence before a step is executed with a dd statement that references the dataset which may or may not exist..
Back to top
View user's profile Send private message
deepak.vl

New User


Joined: 17 Feb 2007
Posts: 38
Location: Hyderabad

PostPosted: Tue Feb 27, 2007 12:08 am    Post subject:
Reply with quote

dick scherrer wrote:
Hello,

If step1 "tries to read" and the dataset does not exist, there will not be a recurn-code issued - the job will fail with a jcl error with the information that the dataset does not exist.

Please refer back to the post from superk. You need to verify existence before a step is executed with a dd statement that references the dataset which may or may not exist..


Oops!!!! you r rite Dick....
Can you please elaborate on 'verify existence before a step is executed'. How exactly can we do that.
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Tue Feb 27, 2007 1:11 am    Post subject:
Reply with quote

Hi Deepak,

It is not elegant, but the way i used to check for a dataset (in batch) was to run an IDCAMS/LISTCAT for the dataset in question. If the LISTCAT is successful, IDCAMS sets a zero RC. If the LISTCAT fails, it is non-zero. Testing the return code would be like your suggestion above. The only real difference is that i specify the dsn to a utility and not to a DD statement.

After years of this, i decided that i would make sure the file(s) were always on the system. If there was no data, the file would only have an end-of-file and raise the AT END condition on the first read.

I liked this approach better than doing some kind of dance to use or not use a file that may or may not be cataloged.
Back to top
View user's profile Send private message
deepak.vl

New User


Joined: 17 Feb 2007
Posts: 38
Location: Hyderabad

PostPosted: Tue Feb 27, 2007 8:33 am    Post subject:
Reply with quote

Thanks Dick
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Tue Feb 27, 2007 9:18 am    Post subject:
Reply with quote

You're welcome icon_smile.gif
Back to top
View user's profile Send private message
superk

Moderator Team Head


Joined: 26 Apr 2004
Posts: 4648
Location: Raleigh, NC, USA

PostPosted: Tue Feb 27, 2007 7:13 pm    Post subject: Re: How to check whether dataset exists or not
Reply with quote

Sigh.

So much for trying to get someone to think through the problem and arrive at a solution for themself.

We can't keep spoon-feeding everyone, folks.
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Tue Feb 27, 2007 9:11 pm    Post subject:
Reply with quote

Actually, my mission with that last bit of info was to "air" my preference that "checking for existence" need not be an issue if the design ensures that is an e-o-f when there is no data for the file. It is at least as easy to ensure there is an empty file as it is to check for existence and code around that (IMHO).

I agree that it would be excellent if there was a way to get folks to do some research/attempt, explain what they've researched/tried, and then post where they are stuck, Then we could help.

Answers are sometimes nice, but becoming self-sufficient is far more valuable.

We can only hope.
Back to top
View user's profile Send private message
ibmmainframesyntel

Active User


Joined: 26 Feb 2007
Posts: 126
Location: Chennai

PostPosted: Thu Mar 01, 2007 8:33 pm    Post subject:
Reply with quote

Code:

//SCHECK1 EXEC PGM=IDCAMS,
// COND=(4,LT)
//SYSIN DD *
LISTCAT ENTRIES('NUMGL.MIDAS.NUD.MAININD')
IF MAXCC=8 THEN SET MAXCC=4
//SYSPRINT DD SYSOUT=*
//SYSABEND DD SYSOUT=X,HOLD=YES
//*
Maxcc=04-dataset does not existing.....
Maxcc=00 dataset existing


Above jcl,we can come to to knw weather it is exixting or not.....

but my requirements is

to find the dataset in the PROC according to the symbolic parameter..

It will be like this......
Exec procname,MIDAS=ww,NUD=rr
Inside the proc
Code:

//SCHECK1 EXEC PGM=IDCAMS,
// COND=(4,LT)
//SYSIN DD *
LISTCAT ENTRIES('NUMGL.&MIDAS..&NUD..MAININD')
IF MAXCC=8 THEN SET MAXCC=4
//SYSPRINT DD SYSOUT=*
//SYSABEND DD SYSOUT=X,HOLD=YES
//*
Maxcc=04-dataset does not existing.....
Maxcc=00 dataset existing
Back to top
View user's profile Send private message
ibmmainframesyntel

Active User


Joined: 26 Feb 2007
Posts: 126
Location: Chennai

PostPosted: Thu Mar 01, 2007 8:34 pm    Post subject: Re: How to check whether dataset exists or not
Reply with quote

superk wrote:
Ask yourself, how would you do this in TSO (TSO, not ISPF) if you needed to? The method would be the same.


plz explain it clearly........
Back to top
View user's profile Send private message
ibmmainframesyntel

Active User


Joined: 26 Feb 2007
Posts: 126
Location: Chennai

PostPosted: Thu Mar 01, 2007 8:43 pm    Post subject:
Reply with quote

hi people.........
give a good solution........
it will be more helpful for me....

can we use symbolic parameter in the control statement
Back to top
View user's profile Send private message
superk

Moderator Team Head


Joined: 26 Apr 2004
Posts: 4648
Location: Raleigh, NC, USA

PostPosted: Thu Mar 01, 2007 8:47 pm    Post subject:
Reply with quote

ibmmainframesyntel wrote:
can we use symbolic parameter in the control statement


No. Symbolic parameters can only be used by the JCL. A program will not know how to resolve the variables.
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3158
Location: Tucson AZ

PostPosted: Thu Mar 01, 2007 8:49 pm    Post subject: Re: How to check whether dataset exists or not
Reply with quote

ibmmainframesyntel wrote:
superk wrote:
Ask yourself, how would you do this in TSO (TSO, not ISPF) if you needed to? The method would be the same.
plz explain it clearly........
Finally got to reading instead of asking?
Back to top
View user's profile Send private message
superk

Moderator Team Head


Joined: 26 Apr 2004
Posts: 4648
Location: Raleigh, NC, USA

PostPosted: Thu Mar 01, 2007 8:50 pm    Post subject: Re: How to check whether dataset exists or not
Reply with quote

The best thing for you to do is, of course, use a PARM:

Code:

//STEPXXXX EXEC PGM=XXX,PARM='NUMGL.&MIDAS..&NUD..MAININD'


and then have the program XXX run the LISTCAT command:

Code:

LISTCAT ENTRIES('resolved entry name passed from PARM')
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3158
Location: Tucson AZ

PostPosted: Thu Mar 01, 2007 8:51 pm    Post subject:
Reply with quote

ibmmainframesyntel wrote:
hi people.........
give a good solution........
it will be more helpful for me....
can we use symbolic parameter in the control statement
Give a good question, we'll be able to be more helpful for you...
Is this related to the current subject or are you starting another thread?
Back to top
View user's profile Send private message
ibmmainframesyntel

Active User


Joined: 26 Feb 2007
Posts: 126
Location: Chennai

PostPosted: Fri Mar 02, 2007 6:39 pm    Post subject: Re: How to check whether dataset exists or not
Reply with quote

superk wrote:
The best thing for you to do is, of course, use a PARM:

Code:

//STEPXXXX EXEC PGM=TTT,PARM='NUMGL.&MIDAS..&NUD..MAININD'


and then have the program TTT run the LISTCAT command:

Code:

LISTCAT ENTRIES('resolved entry name passed from PARM')


please explain it clearly............

i am not getting exactly.........
Back to top
View user's profile Send private message
superk

Moderator Team Head


Joined: 26 Apr 2004
Posts: 4648
Location: Raleigh, NC, USA

PostPosted: Fri Mar 02, 2007 7:33 pm    Post subject: Re: How to check whether dataset exists or not
Reply with quote

Let me try to illustrate:

Let's say your job looks like this:

Code:

//MYJOB JOB (...),...                             
//*                                                     
//JS01     EXEC MYPROC,MIDAS='A',NUD='B'               
//*                                                     


and the PROC MYPROC looks like this:

Code:

//MYPROC   PROC MIDAS=,NUD=                                         
//*                                                                 
//SCHECK1  EXEC PGM=IEFBR14,PARM='NUMGL.&MIDAS..&NUD..MAININD'     
//*                                                                 


Now, sumbit the job, and look at the output in JESJCL. Notice how the variables in the JCL have been properly resolved:

Code:

XXSCHECK1  EXEC PGM=IEFBR14,PARM='NUMGL.&MIDAS..&NUD..MAININD'       
XX*                                                                   
//*                                                                   
IEFC653I SUBSTITUTION JCL - PGM=IEFBR14,PARM='NUMGL.A.B.MAININD'


So, whatever program/utility you choose to use in STEP SCHECK1 will receive the proper value via the PARM statement.

Unless you see that "IEFC653I SUBSTITUTION JCL" message, then the variables are not being resolved by the Internal Reader.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> All Other Mainframe Topics All times are GMT + 6 Hours
Goto page 1, 2  Next
Page 1 of 2

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts What is the command to check MODE of ... rohanthengal CLIST & REXX 6 Fri Nov 18, 2016 1:48 pm
No new posts FTP - JCL failed while passing FTP co... Suneetha1612 JCL & VSAM 12 Wed Nov 16, 2016 7:33 pm
No new posts Check System time(Minute) Using TIME1... balaji81_k DFSORT/ICETOOL 5 Fri Nov 11, 2016 10:53 am
No new posts To trim spaces in a pipe delimited da... Nish84 COBOL Programming 16 Mon Oct 10, 2016 1:54 pm
No new posts Allocate dataset withour BLKSIZE Susanta CLIST & REXX 2 Thu Sep 22, 2016 11:51 am


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us