How to check for a file existence on SFTP server using JCL

Discussion of the COZBATCH utility for z/OS
Post Reply
kssrao1
Posts: 1
Joined: Thu Jul 15, 2010 10:06 pm
Location: lincoln ne
Contact:

How to check for a file existence on SFTP server using JCL

Post by kssrao1 »

Lets say my file name is abc.txt. If this file is found on SFTP server then I need to execute another procedure jcl, named as procb.
If abc.txt file is not found then no need to execute procb

Here is the requirement

Job A will need to have two procs named as proc a and proc b

JobA
------
Step1 exec proca
Step2 exec procb (Note: Step2 will be executed if file, abc.txt is found on the SFTP server else bypass step2)

Proca: This proc will look for a file, abc.txt on SFTP server then sets return code 0 if it is found else sets return code other than 0. Can you please guide me how to code this especially setting up the return code and passing back to jcl and use the same return code in the subsequent steps
Procb: Based on the proc a return code this proc will be executed.
dovetail
Site Admin
Posts: 2022
Joined: Thu Jul 29, 2004 12:12 pm

Post by dovetail »

If you modify the "RUNSFTP" sample JCL and replace the line:

Code: Select all

get $remotefile //DD:DOWNLOAD
with:

Code: Select all

ls $remotefile
You will get a CC=1 from the STEP if the file doesn't exist, and CC=0 if it does.
Post Reply