Sign In

Dz Challenge: Tips and Techniques Got a great tip or technique to share?
z & A > Dz Challenge: Tips and Techniques > Use FTP to submit JCL and retrieve output View modes: 
User avatar
Member
Member
marlun - 10/9/2012 6:11:17 PM
   
Use FTP to submit JCL and retrieve output
Surprisingly, FTP can be used to submit jobs and retrieve output from a Windows machine. Using the FILETYP=JES command, the stream will be directed to the JES (Job Entry Subsystem) spool and the job will get submitted like it was initiated from ISPF. I find this very helpful when automating mainfame data extraction and transferring/formatting them to Excel spreadsheets.

SUBMITTING
First step would be to create an FTP input file (e.g. INPUT.TXT) which will contain the userid, password, file type, put command and lastly, the quit command. The TESTJCL.TXT contains the actual jcl that needs to be submitted. As such, no control statement should not exceed 80 characters.

File: INPUT.TXT
mvsuser
pass123
quote site filetype=jes
put TESTJCL.TXT
quit

Next would be to run the FTP command. Open a command prompt window by typing CMD at Windows Start>Search box. Change directory to where the input.txt and testjcl.txt files are located and run the FTP command below:

ftp -s:input.txt ftpurlhere.com

The output would look like this:

C:\Users\mmvaldez\Documents>ftp -s:input.txt ftpurlhere.com
Connected to ftpurlhere.com.
220-FTPD1 IBM FTP CS V1R13 at ftpurlhere.com, 14:06:14 on 2012-10-09.
220 Connection will close if idle for more than 10 minutes.
User (ftpurlhere.com:(none)):
331 Send password please.

230 MVSUSER is logged on. Working directory is "MVSUSER.".
ftp> quote site filetype=jes
200 SITE command was accepted
ftp> put testjcl.txt
200 Port request OK.
125 Sending Job to JES internal reader FIXrecfm 80
250-It is known to JES as JOB14351
250 Transfer completed successfully.
ftp: 1808 bytes sent in 0.06Seconds 32.29Kbytes/sec.
ftp> quit
221 Quit command received. Goodbye.

Notice the job number (JOB14351).

RETRIEVING
Once the job is done, run the FTP command below using a file like OUTPUT.TXT. Note that the filetype is now set to 'seq' which means that it is now getting a sequential file as in our example 'MVSUSER.SUMMARY.REPORT.TXT' which is an output of the JCL testjcl.txt.

ftp -s:output.txt ftpurlhere.com

File: OUTPUT.TXT
mvsuser
pass123
quote site filetype=seq
get SUMMARY.REPORT.TXT
quit


Now how to know that the job has completed?

WAITING FOR JOB TO FINISH.
In Windows, VBScript (or Powershell) can be used to fully automate all these steps.

Set a programmed loop using this FTP file (ISJOBDONE.TXT).

File: ISJOBDONE.TXT
mvsuser
pass123
quote site filetype=jes
get <jobname>.X JCLJOB.txt
quit

The filetype = jes and notice the '.X' suffixed on the job name. This indicates an extract of all the job's SYSOUT into the output file JCLJOB.txt and search for the string "No spool files available for <jobname>".

If this string is not found, then it means that the job is finished.


1