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
-
snkdbpc
- Posts: 24
- Joined: Mon Oct 22, 2012 5:39 pm
- Skillset: Beginner
- Referer: Google
- 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.
-
snkdbpc
- Posts: 24
- Joined: Mon Oct 22, 2012 5:39 pm
- Skillset: Beginner
- Referer: Google
Re: Transfer a file to mainframe using FTP
Thank you, it worked 
-
NicC
- 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
- 5563
-
by Pedro
View the latest post
Thu Sep 29, 2022 12:11 am
-
-
- 1
- 4173
-
by Robert Sample
View the latest post
Sun Feb 20, 2022 8:04 pm
-
- 0
- 4068
-
by aarvalar1
View the latest post
Mon Sep 09, 2024 7:21 pm
-
-
Copying All Data Off An Old Mainframe
by zunebuggy » Wed Sep 25, 2024 1:10 am » in Mainframe Security - 0
- 4007
-
by zunebuggy
View the latest post
Wed Sep 25, 2024 1:10 am
-
-
-
Dropped records when FTP from mainframe to server
by MLK2348 » Tue Mar 19, 2024 9:19 pm » in All other Mainframe Topics - 2
- 6284
-
by sergeyken
View the latest post
Tue Apr 02, 2024 9:32 pm
-