How to check for existence of Unix System Services files
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.