【问题标题】:How to create dataset on mainframe using FTP from java如何使用来自 java 的 FTP 在大型机上创建数据集
【发布时间】:2019-02-10 07:52:32
【问题描述】:

我正在尝试使用 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】:

    根据您的问题,这是针对 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");
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-10-30
      • 1970-01-01
      • 2021-12-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多