如何使用FTP从FTP在大型机上创建数据集

问题描述 投票:2回答:1

我正在尝试使用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中设置。 但是,我想创建一个PS数据集。任何人都可以建议一种方法。

java ftp mainframe
1个回答
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");
© www.soinside.com 2019 - 2024. All rights reserved.