views:

343

answers:

1

The following is the code that uploades a bytearray into a file DSN on our mainframe. It works very well. What I want to do is upload the jcl which should then start to execute. That's the part I am stuck on. I used to be able to do it through WININET, but I want to get away from that and use the better FTP commands in vb.net

Public Shared Sub UploadToMainFrame( _
    ByVal ftpHost As String, _
    ByVal ftpMainframeDSN As String, _
    ByVal UserName As String, _
    ByVal Password As String, _
    ByVal DataToUpload As String)

    Dim ftpRequest As FtpWebRequest
    Dim ftpFullMainframePath = String.Format("ftp://{2}//'{3}'", ftpHost, ftpMainframeDSN)

    ftpRequest = WebRequest.Create(ftpFullMainframePath)
    ftpRequest.Credentials = New NetworkCredential(UserName, Password)
    ftpRequest.KeepAlive = True
    ftpRequest.UseBinary = False
    ftpRequest.Method = WebRequestMethods.Ftp.UploadFile

    ftpRequest.

    Dim byteArray() As Byte = StrToByteArray(DataToUpload)

    ftpRequest.ContentLength = byteArray.Length

    Dim ftpStream As Stream = ftpRequest.GetRequestStream()
    ftpStream.Write(byteArray, 0, byteArray.Length)
    ftpStream.Close()
    ftpStream = Nothing
    ftpRequest = Nothing

End Sub
+1  A: 

If you want your uploaded file to be treated as a JCL job, it's a simple matter to put:

quote site filetype=jes

into the FTP commands.

This will direct JES to treat the incoming dataset as JCL and automatically submit it.

How you would achieve that with VB is not within my domain but the following works fine from cmd.exe:

ftp -n bigiron.com -s:bigiron.ftp

with bigiron.ftp containing:

user MYNAME MYPASSWORD
quote site filetype=jes
quote site jeslrecl=80
put commands.jcl
bye

If, for some reason, you can't do this from within VB, my next move would be to have a started task running under z/OS which monitored a specific data set and submitted any new members that appeared there.

I'd use the sentinel method to ensure you're not trying to submit half-uploaded jobs:

  • client uploads member into date dataset (e.g., "DATA.MYJOB").
  • client then uploads dummy member into sentinel dataset (e.g., "SENTINEL.MYJOB").
  • started task continuously looks for new members in sentinel dataset.
  • if found, submits the equivalent data member to JES and deletes both sentinel and data members.

We've actually used this method before when sysprogs weren't keen on allowing those foreign machines direct access to JES (despite passwords).

Update, after a bit of searching:

It doesn't look good for the "quote site" solution. This post from 2006 (but with updates well into 2009) seems to indicate MS won't allow "quote site" to be implemented since it would expose the inner workings of their code. I won't comment of the validity of that argument and their reasoning may have changed, but I can't see anything in the current docs that indicates they've added this feature.

So I guess you're stuck with an external FTP solution.

paxdiablo