2

I'm running batch Java on an IBM mainframe under JZOS. The job creates 0 - 6 ".txt" outputs depending upon what it finds in the database. Then, I need to convert those files from Unix to MVS (ebcdic) and I'm using OCOPY command running under IKJEFT01. However, when a particular output was not created, I get a JCL error and the job ends. I'd like to check for the presence or absence of each file name and set a condition code to control whether the IKJEFT01 steps are executed, but don't know what to use that will access the Unix file pathnames.
I have resolved this issue by writing a COBOL program to check the converted MVS files and set return codes to control the execution of subsequent JCL steps. The completed job is now undergoing user acceptance testing. Perhaps it sounds like a kludge, but it does work and I'm happy to share this solution.

zarchasmpgmr
  • 1,302
  • 8
  • 20
Mike GH
  • 793
  • 6
  • 12
  • I just stumbled across this. I've done this in JCL via PGM=BPXBATCH in compile/assemble job streams where the source files were checked out of a source repository, and depending on release may or may not exist--definitely not where you want a JCL error. Let me dig up my JCL in the next day or two and I'll post it here. – zarchasmpgmr Jan 22 '12 at 02:03

1 Answers1

2

The simplest way to do this in JCL is to use BPXBATCH as follows:

//EXIST    EXEC PGM=BPXBATCH,
// PARM='pgm /bin/cat /full/path/to/USS/file.txt'
//*
//         IF  EXIST.RC = 0
//* do whatever you need to
//         ENDIF

If the file exists, the step ends with CC 0 and the IF succeeds. If the file does not exist, you get a non-zero CC (256, I believe), and the IF fails.

Since there is no //STDOUT DD statement, there's no output written to JES.

The only drawback is that it is another job step, and if you have a lot of procs (like a compile/assemble job), you can run into the 255 step limit.

zarchasmpgmr
  • 1,302
  • 8
  • 20
  • 1
    Thanks. The COBOL program also adds a step, but it can write to JES and I can choose the return codes to use for conditioning subsequent steps. Also, I can check multiple files in one step. – Mike GH Feb 22 '12 at 15:28