Is there any exception handling in JCL?



JES, JES2, JCL utilities, IDCAMS, Compile & Run JCLs, PROCs etc...

Is there any exception handling in JCL?

Postby skankatala » Sat Jan 14, 2012 9:18 pm

For example:


//copyproc    PROC
//Step EXEC PGM=SORT
//Sortin dd dsn=&dataset1,disp=shr
//sortout dd dsn=&dataset2,d
//               Disp=(new.catlg,delete)
//                .........................
//                .........................
//Sysin dd *
OPTION=COPY
//                  PEND
//*
//*
//copstep  exec copyproc,dataset1=AAA.BBB.CCCC1,dataset2=DDD.EEE.FFF1
//copstep  exec copyproc,dataset1=AAA.BBB.CCCC2,dataset2=DDD.EEE.FFF2
//copstep  exec copyproc,dataset1=AAA.BBB.CCCC3,dataset2=DDD.EEE.FFF3
//copstep  exec copyproc,dataset1=AAA.BBB.CCCC4,dataset2=DDD.EEE.FFF4


While executing this job,
if third dataset (DDD.EEE.FFF3) is already exists, this is showing JCL error saying "file already exists".
I am submitting this job through Internal reader, So, if an output dataset exists already, all the process is stopped. Is there a way to avoid this problem for smooth running of my job?????????????
skankatala
 
Posts: 42
Joined: Sun Dec 11, 2011 9:45 am
Location: Hyderabad
Has thanked: 0 time
Been thanked: 0 time

Re: Is there any exception handling in JCL?

 

Re: Is there any exception handling in JCL?

Postby enrico-sorichetti » Sat Jan 14, 2012 9:42 pm

define smooth running....

the basic approach would be to add a step to delete all the dataset before starting the copy..


do You realize that the procedure as written will work only on zOS 1.13 onwards ?
cheers
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort
enrico-sorichetti
Global moderator
 
Posts: 2643
Joined: Fri Apr 18, 2008 11:25 pm
Has thanked: 0 time
Been thanked: 130 times

Re: Is there any exception handling in JCL?

Postby steve-myers » Sun Jan 15, 2012 1:21 am

Other than handling condition code and ABEND processing, no, there is no exception handling in JCL. However, this trick has been used for years to conditionally delete datasets.
//A       EXEC PGM=IEFBR14
//DELDS    DD  DISP=(MOD,DELETE),
//             UNIT=SYSDA,
//             SPACE=(TRK,0),
//             DSN=xxx
This works because DISP=MOD is itself conditional; if the dataset does not exist the system will allocate the dataset, but if the dataset does exist the system will use it. This scheme is not perfect; if the dataset is allocated on tape I'm not sure what will happen. I generally use UNIT=SYSALLDA rather than UNIT=SYSDA just in case the dataset exists on direct access storage that is not in SYSDA. If the dataset is cataloged on tape, you have to use something like this
//A       EXEC PGM=IDCAMS
//SYSPRINT DD  SYSOUT=*
//SYSIN    DD  *
  DELETE xxx NOSCRATCH NONVSAM
The problem with this is if the dataset is on disk, before SMS the dataset would not be deleted.

T?his is unconventional:
//A       EXEC PGM=IKJEFT01,
// PARM='DELETE ''xxx'' NOSCRATCH NONVSAM'
//SYSTSPRT DD  SYSOUT=*
//SYSTSIN  DD  DUMMY
steve-myers
Global moderator
 
Posts: 1885
Joined: Thu Jun 03, 2010 6:21 pm
Has thanked: 4 times
Been thanked: 197 times

Re: Is there any exception handling in JCL?

Postby skankatala » Sun Jan 15, 2012 7:09 pm

Hi Steve,

The output data set is to be on Tape drive. I do not wish to delete any data set, if a data set is already cataloged, the copy operation should not be performed.
skankatala
 
Posts: 42
Joined: Sun Dec 11, 2011 9:45 am
Location: Hyderabad
Has thanked: 0 time
Been thanked: 0 time

Re: Is there any exception handling in JCL?

Postby Akatsukami » Sun Jan 15, 2012 7:44 pm

Write some Rexx, or turn the task over to someone who does know Rexx.
"You have sat too long for any good you have been doing lately ... Depart, I say; and let us have done with you. In the name of God, go!" -- what I say to a junior programmer at least once a day
User avatar
Akatsukami
Global moderator
 
Posts: 1053
Joined: Sat Oct 16, 2010 2:31 am
Location: Bloomington, IL
Has thanked: 6 times
Been thanked: 51 times

Re: Is there any exception handling in JCL?

Postby steve-myers » Mon Jan 16, 2012 2:00 am

skankatala wrote:Hi Steve,

The output data set is to be on Tape drive. I do not wish to delete any data set, if a data set is already cataloged, the copy operation should not be performed.
In other words, you want something like this -
//CONDCOPY PROC INDS='?',OUTDS='?'
//A       EXEC PGM=IKJEFT1A,
//             PARM='LISTCAT ENT(''&OUTDS'')'
//SYSTSPRT DD  SYSOUT=*
//SYSTSIN  DD  DUMMY
//         IF  A.RC ¬= 0 THEN
//B       EXEC PGM=IEBGENER
//SYSPRINT DD  SYSOUT=*
//SYSUT1   DD  DISP=SHR,DSN=&INDS
//SYSUT2   DD  DISP=(,CATLG),UNIT=SYSDA,
//             SPACE=(TRK,1),DSN=&OUTDS
//SYSIN    DD  DUMMY
//       ENDIF
//        PEND
Obviously, the IEBGENER step has to be altered for SYSUT2 to go to tape, but that's the general idea. Less obviously, the output dataset cannot be a GDG. However, this will get you started.
steve-myers
Global moderator
 
Posts: 1885
Joined: Thu Jun 03, 2010 6:21 pm
Has thanked: 4 times
Been thanked: 197 times

Re: Is there any exception handling in JCL?

Postby Anuj Dhawan » Wed Jan 18, 2012 7:58 pm

  • "exception handling" is a Java-term.
  • JCL is not a programming langauge like Java though it ends with the word "language". So there is no such thing as "exception handling" in JCL. As a programmer, you need to tell this to your Job.
  • Your first post and the last post are pretty differnt than each other. Either you use IEFBR14 as suggested or execute U11RMS if you have CA11.
But is that what you really want or what you post in the latest post or...?
Anuj
Anuj Dhawan
 
Posts: 274
Joined: Mon Feb 25, 2008 3:53 am
Location: Mumbai, India
Has thanked: 6 times
Been thanked: 4 times

Re: Is there any exception handling in JCL?

Postby steve-myers » Wed Jan 18, 2012 8:35 pm

Anuj - the TS seems to have disappeared.
steve-myers
Global moderator
 
Posts: 1885
Joined: Thu Jun 03, 2010 6:21 pm
Has thanked: 4 times
Been thanked: 197 times


Return to JCL