IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

JCL : How to check Dataset exist or not?


IBM Mainframe Forums -> JCL & VSAM
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
mrar_160

New User


Joined: 14 Sep 2005
Posts: 48

PostPosted: Mon May 29, 2006 7:44 am
Reply with quote

HI all..
I have 1 question, how can i check wheater dataset A is exist or not?
If dataset A is not exist, then proceed the next step.. But the dataset A is exist, the job will stop.
Back to top
View user's profile Send private message
Bharanidharan

New User


Joined: 20 Jun 2005
Posts: 86
Location: Chennai, India

PostPosted: Mon May 29, 2006 10:03 am
Reply with quote

Try this.
Code:

//JS10     EXEC PGM=IDCAMS       
//SYSPRINT DD  SYSOUT=*           
//SYSIN    DD  *                 
  LISTCAT ENTRIES('AAA.BBB')
/*                               

IDCAMS will return RC=4 if the dataset AAA.BBB is not available in the catalog. You can then introduce IF... ENDIF or decide to force terminate the job, as the case may be.
Back to top
View user's profile Send private message
mrar_160

New User


Joined: 14 Sep 2005
Posts: 48

PostPosted: Mon May 29, 2006 1:44 pm
Reply with quote

Ok, thank..I will try first.
Back to top
View user's profile Send private message
mrar_160

New User


Joined: 14 Sep 2005
Posts: 48

PostPosted: Thu Jun 01, 2006 7:14 am
Reply with quote

Bharanidharan,
i had tried. How can i list for nonsms dataset??
Is there any parameter i need to insert?
Back to top
View user's profile Send private message
Bharanidharan

New User


Joined: 20 Jun 2005
Posts: 86
Location: Chennai, India

PostPosted: Thu Jun 01, 2006 10:44 am
Reply with quote

hmm... I never had the blessing of trying out for non-SMS datasets in my system. But you can try this (I didn't test it though):
Code:

//JS10     EXEC PGM=IDCAMS       
//SYSPRINT DD  SYSOUT=*           
//SYSIN    DD  *                 
  LISTCAT ENTRIES('AAA.BBB') CATALOG('catlgname/password')
/*                               

where catlgname is the name of the catalog having the entry; password is an optional parameter and must be provided if catalog is password protected.
FYI, the full list of admissible parmaters is:
Code:

LISTCAT   CATALOG('catname/password')                         
          LIBRARY('lib_name')                                 
          FILE('dname')                                       
          OUTFILE('dname')                                   
          LEVEL('level') | ENTRIES('entryname/password' ...) |
          LIBRARYENTRIES('library_entryname') |               
          VOLUMEENTRIES('volume_entryname')                   
          CREATION('nnnn')                                   
          EXPIRATION('nnnn')                                 
          NOTUSABLE                                           
          CLUSTER  DATA  INDEX  ALIAS  SPACE  NONVSAM         
              USERCATALOG  GENERATIONDATAGROUP  PAGESPACE     
              ALTERNATEINDEX  PATH                           
          ALL | NAME | HISTORY | VOLUME | ALLOCATION         
Back to top
View user's profile Send private message
parikshit123

Active User


Joined: 01 Jul 2005
Posts: 269
Location: India

PostPosted: Thu Jun 01, 2006 1:10 pm
Reply with quote

Hi,

I think this is also another solution

Code:

//*********************************************************************
//* FILE NOT EXISTING :  RC = 12                                       
//* EMPTY FILE        :  RC = 04                                       
//* DATA FILE         :  RC = 00                                       
//*********************************************************************
//STEP010  EXEC PGM=IDCAMS                                             
//SYSUDUMP DD SYSOUT=C                                                 
//SYSOUT   DD SYSOUT=*                                                 
//SYSPRINT DD SYSOUT=*                                                 
//FILEIN   DD DSN=TTYA.TEST.FILE1,DISP=SHR                             
//SYSIN    DD *                                                         
  PRINT INFILE(FILEIN) -                                               
      CHARACTER COUNT(1)                                               
/*                                                                     
//*                                                                     
Back to top
View user's profile Send private message
Bharanidharan

New User


Joined: 20 Jun 2005
Posts: 86
Location: Chennai, India

PostPosted: Thu Jun 01, 2006 2:57 pm
Reply with quote

Minor correction Parikshit -
If file doesn't exist, your job would not execute due to JCL error. For mrar_160's purpose, execution must continue; hence the usage of INDATASET rather than INFILE.

Code:

//*********************************************************************
//* FILE NOT EXISTING :  RC = 12                                       
//* EMPTY FILE        :  RC = 04                                       
//* DATA FILE         :  RC = 00                                       
//*********************************************************************
//STEP010  EXEC PGM=IDCAMS                                             
//SYSUDUMP DD SYSOUT=C                                                 
//SYSOUT   DD SYSOUT=*                                                 
//SYSPRINT DD SYSOUT=*                                                 
//SYSIN    DD *                                                         
  PRINT IDS('AAA.BBB') -                                               
      CHARACTER COUNT(1)                                               
/*                                                                     
//*                                                                     


In addition, I am not sure if PRINT can be used for non-SMS datasets (since mrar_160 has already brought up this issue); it doesn't seem to have parameters for specifying catalogs.
Back to top
View user's profile Send private message
mrar_160

New User


Joined: 14 Sep 2005
Posts: 48

PostPosted: Fri Jun 02, 2006 7:08 am
Reply with quote

Yes bharanidharan, you are in line with me..
The solution you gave to me earlier only can list the sms dataset..I tried to list my desire dataset (nonsms dataset) then i got RC4 with msg :

LISTCAT ENTRIES('AAA.BBB')
IDC3012I ENTRY AAA.BBB NOT FOUND
IDC3009I ** VSAM CATALOG RETURN CODE IS 8 - REASON CODE IS IGG0CLEG-42
IDC1566I ** AAA.BBB NOT LISTED


I also had tried your solution below, but it seen didnot fine the nonsms dataset..the msg is :

Code:
PRINT IDS('AAA.BBB') -                                       
CHARACTER COUNT(1)                                                     
IKJ56228I DATA SET AAA.BBB IN CATALOG OR CATALOG CAN       
IKJ56228I NOT BE ACCESSED                                                     
IDC0005I NUMBER OF RECORDS PROCESSED WAS 0                                   
IDC3003I FUNCTION TERMINATED. CONDITION CODE IS 12   



Even the AAA.BBB dataset is exist.
Back to top
View user's profile Send private message
Bharanidharan

New User


Joined: 20 Jun 2005
Posts: 86
Location: Chennai, India

PostPosted: Fri Jun 02, 2006 1:54 pm
Reply with quote

As I said before, PRINT won't possibly work.
But for LISTCAT, did you try the CATALOG option along with ENTRIES?
Back to top
View user's profile Send private message
mrar_160

New User


Joined: 14 Sep 2005
Posts: 48

PostPosted: Fri Jun 02, 2006 3:13 pm
Reply with quote

I had tried using listcat with CATALOG option. but i got problem how to know my ctlgname.
Quote:
catlgname is the name of the catalog having the entry

can you give an example?? I dont understand..
Back to top
View user's profile Send private message
sundaresanjs

New User


Joined: 29 May 2006
Posts: 18
Location: USA

PostPosted: Sun Jun 04, 2006 10:28 am
Reply with quote

hi mrar_160,

its simple logic you can use the step condition for it,
let us take your example, if datasetA exists then it must stop or else it must continue,


Code:

//job........
//step1 exec pgm=IEBGENER
//sysut1 dd dsn=DATASETA.PS,DISP=SHR
//sysut2 dd dsn=DATAB.PS,DISP=(NEW,DELETE,DELETE),
  DCB=(LREC=80,BLK=800,FB)
//*give the parameters accoring to the DATASETA
//sysout dd sysout=*
//sysin dd dummy
//sysprint dd sysout=*
//step2 exec pgm=........,COND=(0,EQ,step1)
//......
//.........
//....
/*


in the above program if the DATASETA exists then the return code will be 0 and the step2 will not execute due to the condition specified,
or you can give COND=ONLY
which specifies that it will execute the step only when the previous step ennded abnormally,

comment any errors,

regards,
Back to top
View user's profile Send private message
mrar_160

New User


Joined: 14 Sep 2005
Posts: 48

PostPosted: Mon Jun 05, 2006 6:44 am
Reply with quote

sundaresanjs, thank for your reply..
I cannot do like that.It is because, there is another job that will allocate dataset A. So, if i allocate dataset A, then the next job will not be able to allocate dataset A.

I need to check the dataset A, if there is dataset A exist, then my job will stop to execute next step.

Now, my problem is the dataset A is in nonsms, so i got problem to check dataset A. The solution that Bharanidharan gave, it only can cater for sms dataset, i tried for nonsms dataset, but it didnt find the nonsms dataset.

Hope anyone here can help.
Tq.
Back to top
View user's profile Send private message
Bharanidharan

New User


Joined: 20 Jun 2005
Posts: 86
Location: Chennai, India

PostPosted: Tue Jun 06, 2006 5:10 pm
Reply with quote

All your catalog entries (VSAM and non-VSAM datasets) are stored in either master catalog or user catalog, may it be SMS or non-SMS managed datasets. You can obtain a list of user catalogs that can contain the datasets created in your LPAR using IDCAMS LISTCAT USERCATALOG. These catalogs are created during the initial setup and can be changed (with limitations) at any time.
Now, while creating SMS datasets, if catalog name is not mentioned, file would be created in the default system catalog (here I am not sure how to identify which is the default catalog; you may need to ask your storage group). Specific storage classes, and hence volumes, (or a group of them) would be linked with each catalog. You can override the default catalog with CATALOG option while creating.
But for non-SMS datasets, I believe you need to mention catalog name (and pwd if it is pwd controlled) while creating it. And, if your dataset is created usually in a particular volume serial (or unit), then it would always be created in one catalog only, since that volume group is related with that catalog.

What you need to do:
1. If you have some other datasets defined in the same volume (or storage class) in which you expect your file to be created, find the catalog in which they reside by using LISTCAT command (or using File-Aid;Fileaid will clearly show you the catalog).
2. Plug in the catalog name in the CATALOG option.
Back to top
View user's profile Send private message
Salil Pant

New User


Joined: 03 Jun 2009
Posts: 3
Location: India

PostPosted: Wed Jun 10, 2009 12:54 pm
Reply with quote

Is this command applicable to check the presence of member of a PDS? I tried using it but it is not giving me desired results.
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8797
Location: Welsh Wales

PostPosted: Wed Jun 10, 2009 1:02 pm
Reply with quote

Salil Pant wrote:
Is this command applicable to check the presence of member of a PDS? I tried using it but it is not giving me desired results.

Mmmmmmmmmmm, now where did I put my crystal ball to see exactly what the problem is ?

Maybe in the meantime you could ellaborate a little on that wonderful phrase "I tried using it but it is not giving me desired results"
Back to top
View user's profile Send private message
Salil Pant

New User


Joined: 03 Jun 2009
Posts: 3
Location: India

PostPosted: Wed Jun 10, 2009 1:37 pm
Reply with quote

It just means that can we use LISTCAT command to check if member of a PDS is present or not?

I tried giving

LISTCAT ENTRIES('XXXX.YYYY(member)')

But this is checking only for the presence of PDS not specifically for the member
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8797
Location: Welsh Wales

PostPosted: Wed Jun 10, 2009 2:24 pm
Reply with quote

Checking for members you will probably need a REXX exec to use the SYSDSN function.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> JCL & VSAM

 


Similar Topics
Topic Forum Replies
No new posts FINDREP - Only first record from give... DFSORT/ICETOOL 3
No new posts Map Vols and Problem Dataset All Other Mainframe Topics 2
No new posts SCOPE PENDING option -check data DB2 2
No new posts Check data with Exception Table DB2 0
No new posts Allocated cylinders of a dataset DB2 12
Search our Forums:

Back to Top