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
Global Moderator
Joined: 26 Apr 2004 Posts: 4652 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: 2358 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
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 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
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 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
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
You're welcome |
|
Back to top |
|
|
superk
Global Moderator
Joined: 26 Apr 2004 Posts: 4652 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
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 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
Global Moderator
Joined: 26 Apr 2004 Posts: 4652 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: 3156 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
Global Moderator
Joined: 26 Apr 2004 Posts: 4652 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: 3156 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
Global Moderator
Joined: 26 Apr 2004 Posts: 4652 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 |
|
|
ibmmainframesyntel
Active User
Joined: 26 Feb 2007 Posts: 126 Location: Chennai
|
|
|
|
In the PROC
//MYPROC PROC MIDAS=,NUD=
//*
//SCHECK1 EXEC PGM=IEFBR14,PARM='NUMGL.&MIDAS..&NUD..MAININD'
//*
using IEFBR14,what u are doing?
After this if the dataset is not found what it will be?
weather it will be JCLERROR or RC=08
let me knw
thank you |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
Hello,
IEFBR14 is just an example in this case to demonstrate the symbolic parameter substitution. Instead of IEFBR14 you would use your own program (TTT to continue the example above).
From the dataset name constructed from the constants and the variables, create the LISTCAT control statement shown above.
When you execute the IDCAMS step, you will get a return code not a JCL error. |
|
Back to top |
|
|
ibmmainframesyntel
Active User
Joined: 26 Feb 2007 Posts: 126 Location: Chennai
|
|
|
|
Ok..
hw to mention the the listcat entries...
LISTCAT ENTRIES('resolved entry name passed from PARM')
I don't knw...
pls tell me....
the output of the program will have the expanded dataset name
by substituting the symbolic parameters..
that i got itt.
but hw i mention the output in LISTCAT(' ')
let me knw... |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
Hello,
In your program that recieves the parm info, define an output file with a length of 80. In the jcl for running the program inclulde a DD statement for this file and it will have DISP=(,CATLG,DELETE). Place this output file on dasd and use it as input to a following IDCAMS step.
In your working-storage create an 01 LISTCAT-CTL that has fillers set up with the constant LISTCAT control info. In that same 01, declare a field where you will move the complete dsn.
Once you have the control statement in working-storage, write the 80-byte output record from that LISTCAT control statement.
Good luck and let us know if you would like anyh other info. |
|
Back to top |
|
|
|