I am trying to transfer from the local file system to mainframe via the FTP protocol.I am using the apache.common.net library.The code is as follows,
FTPClient ftp = null;
InputStream in = null;
ftp = new FTPClient();
ftp.connect(hostName);
ftp.login(username, password);
ftp.enterLocalPassiveMode();
ftp.setFileType(FTP.ASCII_FILE_TYPE);
int reply = ftp.getReplyCode();
System.out.println("Received Reply from FTP Connection:" + reply);
if (FTPReply.isPositiveCompletion(reply))
System.out.println("Connected To Server Successfully");
else
System.out.println("Not connected to Server..Check ID,Password,connecivity");
boolean success = ftp.changeWorkingDirectory("'CICS.MAPLIB'");
if (success)
System.out.println("Successfully changed working directory.");
else
System.out.println("Failed to change working directory. See server's reply.");
File f1 = new File(location);
in = new FileInputStream(f1);
boolean done = ftp.storeFile("File", in);
in.close();
if (done)
System.out.println("FILE IS UPLOADED SUCCESSFULY");
else
System.out.println("FILE IS NOT UPLOADED SUCCESSFULLY");
ftp.logout();
ftp.disconnect();
I am taking username,password,hostname and location as parameters to the method.I previously created a PDS named 'USERID.CICS.MAPLIB' in z/OS.Now, the problem I am facing is that the file is not uploaded but however if I am not changing the working directory to 'USERID.CICS.MAPLIB', the file gets uploaded to the location 'USERID.File'.I am seeking to upload the file to a new member in the PDS I created earlier.If anyone has any solution, please help.
Thanks in Advance
Transfer a file to mainframe using FTP
- Stefan
- Posts: 27
- Joined: Tue Aug 21, 2012 3:02 pm
- Skillset: Application development, configuration management, maintaining test environments
- Referer: world wide web
Re: Transfer a file to mainframe using FTP
I don't know nothing about the language you're using, but if you want to upload to USER.CICS.MAPLIB, then you should specify this data set fully qualified as in
Code: Select all
ftp.changeWorkingDirectory("'USER.CICS.MAPLIB'");
There are 10 types of people in the world: Those who understand binary, and those who don't.
Re: Transfer a file to mainframe using FTP
Thank you, it worked 

-
- Global moderator
- Posts: 3025
- Joined: Sun Jul 04, 2010 12:13 am
- Skillset: JCL, PL/1, Rexx, Utilities and to a lesser extent (i.e. I have programmed using them) COBOL,DB2,IMS
- Referer: Google
- Location: Pushing up the daisies (almost)
Re: Transfer a file to mainframe using FTP
Why is this posted in the JAVA section of the forum?
The problem I have is that people can explain things quickly but I can only comprehend slowly.
Regards
Nic
Regards
Nic
-
- Similar Topics
- Replies
- Views
- Last post
-
-
transferring file from pc to mainframe pds member
by valeca » Wed Sep 28, 2022 3:42 am » in TSO & ISPF - 5
- 3357
-
by Pedro
View the latest post
Thu Sep 29, 2022 12:11 am
-
-
- 8
- 5163
-
by enrico-sorichetti
View the latest post
Fri Mar 12, 2021 4:09 pm
-
- 1
- 2887
-
by Robert Sample
View the latest post
Sun Feb 20, 2022 8:04 pm
-
- 1
- 3617
-
by jibanes
View the latest post
Sun Dec 06, 2020 1:41 am
-
- 2
- 2481
-
by brown7
View the latest post
Sun Nov 07, 2021 1:11 pm