In the following JCL, the HFS path /u/woodsmn/jjk does not exist. It raises a JCL error and does not run the COPYHFS step, nor any other steps. I want it to detect the missing file, and run the FAILIND step.
I suspect MVS raises a JCL error and completely ignores any COND conditions that might apply. I was hoping it raise some failure step condition code and behave that way.
How can I re-write this to execute steps when a PATH does not exist?
//WOODSMN1 JOB (1111),MSGLEVEL=(1,1),CLASS=A,MSGCLASS=H,
// USER=WOODSMN,REGION=1M
//COPYHFS EXEC PGM=IKJEFT01
//INHFS DD PATH='/u/woodsmn/jjk',
// PATHOPTS=(ORDONLY),RECFM=VB,LRECL=255,BLKSIZE=32760
//OUTMVS DD DSN=WOODSMN.TESTDS1,
// DISP=(NEW,CATLG,DELETE),
// SPACE=(TRK,(1,1)),
// DCB=(LRECL=80,RECFM=FB,BLKSIZE=8080)
//SYSTSPRT DD SYSOUT=*
//SYSTSIN DD *
OCOPY INDD(INHFS) OUTDD(OUTMVS) CONVERT(NO)
/*
//*
//NETVIEW EXEC PGM=IEFBR14,COND=(0,EQ,COPYHFS)
//*
//SUCCIND EXEC PGM=IEBGENER,REGION=1M,COND=(0,EQ,NETVIEW)
//SYSPRINT DD SYSOUT=*
//SYSUT1 DD *
Attempt to put file succeeded
/*
//SYSUT2 DD PATHOPTS=(ORDWR,OTRUNC,OCREAT),PATHMODE=SIRWXU,
// PATHDISP=(KEEP,DELETE),
// PATH='/u/woodsmn/TESTDS.SUCCESS'
//SYSIN DD DUMMY
//*
//FAILIND EXEC PGM=IEBGENER,REGION=1M,COND=(0,GT,NETVIEW)
//SYSPRINT DD SYSOUT=*
//SYSUT1 DD *
Attempt to put file failed
/*
//SYSUT2 DD PATHOPTS=(ORDWR,OTRUNC,OCREAT),PATHMODE=SIRWXU,
// PATHDISP=(KEEP,DELETE),
// PATH='/u/woodsmn/TESTDS.FAIL'
//SYSIN DD DUMMY
//
Use BPXBATCH to execute a shell command to test the existence of your directory.
//EXIST001 EXEC PGM=BPXBATCH,PARM='SH test -e /u/woodsmn/jjk'
//STDOUT DD SYSOUT=*
//STDERR DD SYSOUT=*
You may have to get a bit more exotic and use the STDPARM DD to pass a `set -o errexit' to get the return code to work exactly as you wish.