Page 1 of 1

Is there any exception handling in JCL?

PostPosted: Sat Jan 14, 2012 9:18 pm
by skankatala
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?????????????

Re: Is there any exception handling in JCL?

PostPosted: Sat Jan 14, 2012 9:42 pm
by enrico-sorichetti
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 ?

Re: Is there any exception handling in JCL?

PostPosted: Sun Jan 15, 2012 1:21 am
by steve-myers
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

Re: Is there any exception handling in JCL?

PostPosted: Sun Jan 15, 2012 7:09 pm
by skankatala
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.

Re: Is there any exception handling in JCL?

PostPosted: Sun Jan 15, 2012 7:44 pm
by Akatsukami
Write some Rexx, or turn the task over to someone who does know Rexx.

Re: Is there any exception handling in JCL?

PostPosted: Mon Jan 16, 2012 2:00 am
by steve-myers
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.

Re: Is there any exception handling in JCL?

PostPosted: Wed Jan 18, 2012 7:58 pm
by Anuj Dhawan
  • "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...?

Re: Is there any exception handling in JCL?

PostPosted: Wed Jan 18, 2012 8:35 pm
by steve-myers
Anuj - the TS seems to have disappeared.