Upload Files to Mainframes from VB.net
I am trying to upload a file from my pc to mainframes. I am trying to upload it using Chilkat FTP2. Below is the code.
The fil开发者_JS百科e I am trying to upload is 2009102600000
Dim ftp As New Chilkat.Ftp2()
Dim success As Boolean
' Any string unlocks the component for the 1st 30-days.'
success = ftp.UnlockComponent("Anything for 30-day trial")
If (success <> true) Then
MsgBox(ftp.LastErrorText)
Exit Sub
End If
ftp.Hostname = "www.myside.com"
ftp.Username = "****"
ftp.Password = "****"
' The default data transfer mode is "Active" as opposed to "Passive".'
' Change it to Passive by setting the Passive property:'
ftp.Passive = true
' Connect and login to the FTP server.'
success = ftp.Connect()
If (success <> true) Then
MsgBox(ftp.LastErrorText)
Exit Sub
End If
' Change to the remote directory where the file will be uploaded.'
success = ftp.ChangeRemoteDir("ABC.SITEUPLOAD.UPLOAD")
If (success <> true) Then
MsgBox(ftp.LastErrorText)
Exit Sub
End If
' Upload a file.'
Dim localFilename As String
localFilename = "c:\2009102600000"
Dim remoteFilename As String
remoteFilename = "2009102600000"
success = ftp.PutFile(localFilename,remoteFilename)
If (success <> true) Then
MsgBox(ftp.LastErrorText)
Exit Sub
End If
ftp.Disconnect()
MsgBox("File Uploaded!")
The error I am getting is dataset not found use MVS dsn name or something like that.
I would really appreciate if you can help me out with this one please.
I'm not at all sure you can treat data set prefixes as directories. When I'm doing uploads to the mainframe with ftp, I always just specify the full target name. I would get rid of the
ftp.ChangeRemoteDir("ABC.SITEUPLOAD.UPLOAD")
section altogether and just change:
remoteFilename = "2009102600000"
to:
remoteFilename = "'ABC.SITEUPLOAD.UPLOAD.2009102600000'"
if it's a sequesntial data set, or:
remoteFilename = "'ABC.SITEUPLOAD.UPLOAD(2009102600000)'"
if it's a member (in which case the data set will have to exist first).
It would also help if you changed the MsgBox
statements so that they included an indication as to what is actually causing the error. Something along the lines of:
MsgBox("Connect error: " & ftp.LastErrorText)
MsgBox("ChangeRemoteDir error: " & ftp.LastErrorText)
MsgBox("PutFile error: " & ftp.LastErrorText)
instead of the generic:
MsgBox(ftp.LastErrorText)
One other point: you'll notice I've put single quotes around the targets above. That's because z/OS has a habit of (sometimes) prefixing your login name to members. It may be that:
put xyz.txt upload(xyz)
is actually trying to put it into yourname.upload(xyz)
. Quoting it will prevent that.
Update: You know, I just noticed something that totally escaped me the first time I read this question. The error message spells it out plainly.
Data set name segments and member names within partitioned data sets are limited to 8 characters. Hence your 'ABC.SITEUPLOAD.UPLOAD(2009102600000)'
is invalid on two counts, the SITEUPLOAD
and the 2009102600000
. Try shortening the names and re-transferring.
Here's the proof:
C:\Documents and Settings\Pax> ftp bigiron
Connected to bigiron.box.com.
220-FTPD1 IBM FTP CS V1R9 at BIGIRON.BOX.COM, 02:15:23 on 2009-11-06.
220 Connection will close if idle for more than 5 minutes.
User (bigiron.box.com:(none)): pax
331 Send password please.
Password:
230 PAX is logged on. Working directory is "PAX.".
ftp> put test.txt 'pax.siteupload'
200 Port request OK.
501 Invalid data set name "'pax.siteupload'". Use MVS Dsname conventions.
ftp> put test.txt 'pax.siteupld'
200 Port request OK.
125 Storing data set PAX.SITEUPLD
250 Transfer completed successfully.
ftp: 177 bytes sent in 0.00Seconds 177000.00Kbytes/sec.
ftp> put test.txt 'pax.jcl(abcdefghi)'
200 Port request OK.
501 Invalid data set name "'pax.jcl(abcdefghi)'". Use MVS Dsname conventions.
ftp> put test.txt 'pax.jcl(abcdefgh)'
200 Port request OK.
125 Storing data set PAX.JCL(ABCDEFGH)
250 Transfer completed successfully.
ftp: 177 bytes sent in 0.00Seconds 177000.00Kbytes/sec.
ftp> bye
221 Quit command received. Goodbye.
Are you sure you don't need to store it as a generational dataset from the root directory? Like this:
'ABC.SITEUPLOAD.UPLOAD.2009102600000(+1)'
精彩评论