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 

Check for the existence of the dataset process the next

 
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
Pavani Donepudi
Beginner


Joined: 07 Apr 2004
Posts: 13
Topics: 7

PostPosted: Thu Dec 11, 2008 2:16 pm    Post subject: Check for the existence of the dataset process the next Reply with quote

Here is my req.

I have a dataset TEST1 which I am not sure if it existing or not in the mainframe. My req is if TEST1 existing in the mainframe then copy it to TEST2 else use the a DUMMY file to copy it to TEST2. Either way I need to create TEST2.

But the catch is, I cannot create a Dummy file dataset is TEST1 dataset is not existing. How can I achieve this. Here are my steps that I am using but the problem is if TEST1 is not existing, then the job is failing with a JCL error stating "DATASET NOT FOUND ON MAIN PROCESSOR M207".

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('TEST1') COUNT(1)
  IF LASTCC=12 THEN SET MAXCC=4
/*   
//*
//* EXECUTE THE FOLLOWING STEP IF THE DATASET IS NOT THERE
//*                                             
// IF (STEP0100.RC EQ 12) THEN                     
//STEP010  EXEC PGM=SORT                         
//SYSPRINT  DD SYSOUT=*                             
//SYSUT1    DD DUMMY                               
//SYSUT2    DD DSN=TEST2,
//             DISP=(NEW,CATLG,DELETE),
//             Rest of the properties follow 
//SYSIN     DD *
   COPY ALL                           
//*                                                 
//* EXECUTE THE FOLLOWING STEP IF THE DATASET IS THERE
//*                                             
// ELSE                                             
//STEP020  EXEC PGM=SORT                         
//SYSPRINT  DD SYSOUT=*                             
//SYSUT1    DD DSN=SHR,DSN=TEST1                               
//SYSUT2    DD DSN=TEST2,
//             DISP=(NEW,CATLG,DELETE),
//             Rest of the properties follow 
//SYSIN     DD *
   COPY ALL                           
//*                                                 
// ENDIF 
//*       
//Continue with the rest of the steps.
Back to top
View user's profile Send private message
taltyman
JCL Forum Moderator
JCL Forum Moderator


Joined: 02 Dec 2002
Posts: 310
Topics: 8
Location: Texas

PostPosted: Thu Dec 11, 2008 2:33 pm    Post subject: Reply with quote

Why do you set cc to 4 and then check for a 12
Back to top
View user's profile Send private message
Pavani Donepudi
Beginner


Joined: 07 Apr 2004
Posts: 13
Topics: 7

PostPosted: Thu Dec 11, 2008 4:04 pm    Post subject: Reply with quote

I was checking for something else. By mistake I forgot to remove the statement of setting MAXCC.

BTW, I got the solution. I changed STEP020.SYSUT1 to have DISP=MOD instead of DISP=SHR.

This way I am eliminating the Processor not to check for the existence of the datasets and therby eliminating the error message DATASET NOT FOUND.

This worked out for me but not sure if this is a better solution.
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


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

PostPosted: Thu Dec 11, 2008 5:25 pm    Post subject: Reply with quote

Pavani Donepudi,

You really don't need 3 steps to get the desired results. Everything can be handled in IDCAMS step itself

Code:

//STEP0100 EXEC PGM=IDCAMS                             
//SYSPRINT DD SYSOUT=*                                 
//DD1      DD DUMMY                                     
//DD2      DD DSN=TEST2,                         
//            DISP=(NEW,CATLG,DELETE),                 
//            UNIT=SYSDA,                               
//            SPACE=(CYL,(1,1),RLSE),                   
//            DCB=(LRECL=nnn,RECFM=zz,BLKSIZE=0)         
//SYSIN    DD  *                                       
  PRINT IDS('test1') COUNT(1)                 
  IF LASTCC = 12 THEN DO                               
     REPRO INFILE(DD1) OUTFILE(DD2)                   
     SET MAXCC=4                                       
     END                                               
  ELSE DO                                               
     REPRO INDATASET('test1') OUTFILE(DD2)   
  END                                                   
//*


Kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
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