我正在尝试使用Java将文本文件FTP传输到大型机。我可以使用以下代码在PDS中创建成员。
//Function to FTP the report
public void sendReport() throws IOException
{
FTPSClient ftp = null;
InputStream in = null;
String protocol="TLS";
//Connecting to mainframe server for ftp transfer
ftp = new FTPSClient(protocol);
ftp.connect(hostname);
ftp.login(user,password);
ftp.execPBSZ(0);
ftp.execPROT("P");
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 Mainframe");
else
System.out.println("Not connected to Mainframe..Check ID or Password");
//Setting mainframe PDS for reports
boolean success = ftp.changeWorkingDirectory("***Mainframe Directory***");
if (success)
System.out.println("Successfully changed PDS.");
else
System.out.println("Failed to change PDS. See Mainframe's reply.");
//Sending Report to mainframe PDS
File f1 = new File(dkReportName);
in = new FileInputStream(f1);
boolean done = ftp.storeFile("DKI"+dkReportName.substring(14,18), in);
in.close();
if (done)
System.out.println("FILE FTP SUCCESSFUL");
else
System.out.println("FILE FTP NOT SUCCESSFUL");
ftp.logout();
ftp.disconnect();
}
在appContext.xml中设置了 user,password和hostname变量。
但是,我想创建一个PS数据集。
任何人都可以提出一种解决方法。
答案 0 :(得分:2)
根据您的问题,这是用于MVS文件空间而不是USS。
使用FTP创建数据集时,您需要向主机提供一些有关文件大小,属性等的信息。
此page on IBM's website概述了可以执行以设置传输的命令列表。基本顺序如下:
site cyl
site pri=5
site sec=5
site recfm=fb
,您可以在一行中组合多个命令:
site lrecl=80 blksize=3120
在传输之前执行这些命令,并且应该为文件分配所需的特征。
根据您的编码示例,下面的示例应该可以正常工作:
ftp.sendCommand("site",
"cyl pri=5 sec=5 recfm=fb filetype=seq lrecl=80 blksize=3120");