View previous topic :: :: View next topic
|
Author |
Message |
ibmmainframesyntel
Active User
Joined: 26 Feb 2007 Posts: 126 Location: Chennai
|
|
|
|
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 |
|
 |
|
|
superk
Moderator Team Head
Joined: 26 Apr 2004 Posts: 4650 Location: Raleigh, NC, USA
|
|
|
|
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 |
|
 |
ofer71
Global Moderator
Joined: 27 Dec 2005 Posts: 2360 Location: Israel
|
|
|
|
LISTDSI & SYSDSN are the methods for you.
O. |
|
Back to top |
|
 |
deepak.vl
New User
Joined: 17 Feb 2007 Posts: 38 Location: Hyderabad
|
|
|
|
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 |
|
 |
dick scherrer
Site Director
Joined: 23 Nov 2006 Posts: 19270 Location: Inside the Matrix
|
|
|
|
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 |
|
 |
deepak.vl
New User
Joined: 17 Feb 2007 Posts: 38 Location: Hyderabad
|
|
|
|
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 |
|
 |
dick scherrer
Site Director
Joined: 23 Nov 2006 Posts: 19270 Location: Inside the Matrix
|
|
|
|
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 |
|
 |
deepak.vl
New User
Joined: 17 Feb 2007 Posts: 38 Location: Hyderabad
|
|
|
|
Thanks Dick |
|
Back to top |
|
 |
dick scherrer
Site Director
Joined: 23 Nov 2006 Posts: 19270 Location: Inside the Matrix
|
|
|
|
You're welcome  |
|
Back to top |
|
 |
superk
Moderator Team Head
Joined: 26 Apr 2004 Posts: 4650 Location: Raleigh, NC, USA
|
|
|
|
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 |
|
 |
dick scherrer
Site Director
Joined: 23 Nov 2006 Posts: 19270 Location: Inside the Matrix
|
|
|
|
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 |
|
 |
ibmmainframesyntel
Active User
Joined: 26 Feb 2007 Posts: 126 Location: Chennai
|
|
|
|
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 |
|
 |
ibmmainframesyntel
Active User
Joined: 26 Feb 2007 Posts: 126 Location: Chennai
|
|
|
|
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 |
|
 |
ibmmainframesyntel
Active User
Joined: 26 Feb 2007 Posts: 126 Location: Chennai
|
|
|
|
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 |
|
 |
superk
Moderator Team Head
Joined: 26 Apr 2004 Posts: 4650 Location: Raleigh, NC, USA
|
|
|
|
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 |
|
 |
William Thompson
Global Moderator
Joined: 18 Nov 2006 Posts: 3158 Location: Tucson AZ
|
|
|
|
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 |
|
 |
superk
Moderator Team Head
Joined: 26 Apr 2004 Posts: 4650 Location: Raleigh, NC, USA
|
|
|
|
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 |
|
 |
William Thompson
Global Moderator
Joined: 18 Nov 2006 Posts: 3158 Location: Tucson AZ
|
|
|
|
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 |
|
 |
ibmmainframesyntel
Active User
Joined: 26 Feb 2007 Posts: 126 Location: Chennai
|
|
|
|
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 |
|
 |
superk
Moderator Team Head
Joined: 26 Apr 2004 Posts: 4650 Location: Raleigh, NC, USA
|
|
|
|
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 |
|
 |
|