0

Currently, My system send file from AS400 to Mainframe by FTP. The downstream Mainframe system will not support FTP any more. FTPS will be the only way to send files to it.

Currently we use com.ibm.as400.access.FTP and this package to execute FTP command. I want to know What package can be used by FTPS from AS400 to Mainframe.

currently ftp code is as follows:

boolean FTPFile(String filepath, String filename, String country) {
    String ftpresult = "";

    String region = bundle.getString("region." + country);
    FTP ftp = new FTP(ftpHost, ftpId, ftpPw);

    try {
        if (country.equals("766") || country.equals("858") 
                || country.equals("761") || country.equals("836")) {
            ftp.setDataTransferType(FTP.BINARY);
        }

        if (ftp.connect()) {
            getLogMsg().append("FTPing SIF file.  Region = " + region,
                    LogMsg.TEXT_MSG);

            String sendname = "'" + ftpDataset + country + ".LSIFATB'";

            getLogMsg().append(
                    "sending file: = " + filepath + filename + " as "
                            + sendname, LogMsg.TEXT_MSG);

            // Korea
            if (country.equals("766") || country.equals("761")) {
                ftp.issueCommand("ltype c 933");
                // ftpresult = ftp.issueCommand("type b 6");
            }

            // Taiwan
            if (country.equals("858") || country.equals("836")) {
                ftp.issueCommand("ltype c 937");
                // ftpresult = ftp.issueCommand("type b 8");
            }

            boolean ftp_res = ftp.put(filepath + filename, sendname);
            // System.out.println("ftp result: " + ftp_res);
            getLogMsg().append("ftp result (sending SIF): " + ftp_res,
                    LogMsg.TEXT_MSG);

            ftpresult = ftp.issueCommand("site filetype=jes");
            System.out.println("ftp command result = " + ftpresult);
            String jobname = bundle.getString("app.sif.jobname." + country);

            // String jobname = "CISBL30D";
            ftp.setDataTransferType(FTP.ASCII);
            ftp_res = ftp.put(bundle.getString("app.sif.directory") + "/"
                    + region + country + "/jcl.txt", "jcl.txt '" + jobname
                    + "'");
            getLogMsg().append("ftp result (sending jcl): " + ftp_res,
                    LogMsg.TEXT_MSG);

            return true;
        }
    } catch(...) {}
}
ArifMustafa
  • 4,617
  • 5
  • 40
  • 48
  • Try [apache commons-net](https://commons.apache.org/proper/commons-net/). That has an FTPS class, and may work for you. – jmarkmurphy Jan 10 '18 at 16:05

1 Answers1

1

I've used the Apache COMMONS Net module to do normal FTP.

It does have a FTPSClient class that should do what you want.

David G
  • 3,940
  • 1
  • 22
  • 30