How do I FTP to/from IBM Mainframe, including Job Submission

robertb_NZ

Well-known member
Joined
May 11, 2010
Messages
146
Location
Auckland, New Zealand
Programming Experience
10+
This replaces thread http://www.vbdotnetforums.com/vb-ne...tp-ibm-mainframe-how-do-i-convert-ebcdic.html as that failed to give me an answer that worked.

Summary
From my VB.NET program I want to be able to use FTP to submit jobs and upload/download data to/from a zOS mainframe. I am dealing with relatively small character-only files, not large binary objects. I can do what I want from a Command Prompt window, but I need to automate this.

Background
Using a Command Prompt window I can achieve what I want by entering FTP commands. For example, this will upload a file: -
FTP
Open <IP>
<userid>
<password>
PUT <local file> <Destination file>
Quit​
To/from EBCDIC conversion is handled automatically at the mainframe end.

To submit a job one precedes the PUT command with Quote Site Filetype=JES and you leave the Destination file out of the PUT statement, i.e.
FTP
Open <IP>
<userid>
<password>
Quote Site Filetype=JES
PUT <local file>
Quit​

To get the job output you replace the PUT with
GET <Jobname>
where the value of <jobname> is given by a message returned with the job submission PUT. Thus you need to be able to recognize a message like
250-It is known to Jes as JOB00391

What I'm trying to do
I need to automate this, but the Microsoft class System.Net.FtpWebRequest does not handle FTP to an EBCDIC machine properly:-
? If I don?t convert the data to EBCDIC on my(Microsoft) side, it arrives in zOS in Ascii where it is gibberish.
? If I convert it before it is sent, the line-ends (VbCrLf) become simply two hex bytes and the data is not properly broken into lines, making it readable but useless.
? Also, it has nothing to support job submission. FtpWebRequest.Method must have a value from System.Net.WebRequestMethods.Ftp, and there's no option to use the FTP QUOTE command.

Approaches that I've tried
I've tried three approaches: -
A. Automating the command sequence that works successfully from the Command Prompt
B. I considered replacing System.Net.FtpWebRequest
C. I am looking for an FTP library that I can use.

Approach A: Automating the command Sequence
I had hoped that it would be easy to send a command to FTP and get the response back, but whether I used the approach of Automate Command Prompt Window (CMD), Redirect Output to Application [2003/2005]-VBForums or created my own code by running Shell through a Process, I could initiate FTP easily but I couldn't seem to send it commands or to get any responses back to my program. I hope that someone can show me how to do this, I'm sure that there's something stupid that I'm doing. However even if I get this approach working I'm concerned that what I develop will depend too much on the specific details of the particular FTP site I'm working with at the moment, and may not be a general solution. I'd like the approach of being able to put code within a Try/Catch so that any FTP error was caught and dealt with properly. However: -

Approach B. Replacing System.Net.FtpWebRequest
A paper "How To Write Pluggable Protocol to Support FTP in Managed Classes by Using Visual C# .NET, How To Write Pluggable Protocol to Support FTP in Managed Classes by Using Visual C# .NET , showed me how to replace FTPWebRequest with my own version. I converted this to VB (in the VB version of this paper the download doesn't work) and studied the replacement. It still doesn't help: while I could easily change the code to allow Method to have the value "Quote site filetype=jes" I can't see how to make this method send TWO commands to the FTP, which is necessary for job submission I think. Or to get the output back so that I know what the job number is.

Approach C - Find a 3rd party library
I'd love to do this. Does anybody have any suggestions. I've tried Google, but I'm not sure that any of the products available will do what I want.

Thank you for reading this far, it's a long posting but I wanted to avoid wasting your time and mine with things that I've already tried. This is a difficult problem because IBM, Microsoft, and I all seem to use different languages. I have solutions that work fine for Java and OS2, but there seems very little that can bridge the world of zOS/EBCDIC and .NET/Ascii.
 
Problem solved with Approach C, Find a 3rd party library. I came across this product from Poland: -
.NET FTP component | Ftp.dll FTP component

I downloaded a trial version, and found that, like most products, it would almost do what I wanted. But how's this for excellent support: -
  • I emailed Limilabs with my problem about midday, New Zealand time (2:00 in the morning in Poland).
  • I had an email back discussing the problem at 8:35PM (10:35 AM), and by 9:44PM I had a Beta version with the features I needed.
  • By 11:22PM and one more Beta release later we'd tested the new version, and it was doing everything I needed.
Well worth the 99 Euro ($NZ154) that the product is going to cost me! Thank you Pawel!
 
Back
Top