1

I have written one Java class to submit JCL to Mainframe JES using FTP. The code is able to submit the JCL but it is not retrieving the JOB log from JES SPOOL.

package com.test;



import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.SocketException;

import org.apache.commons.net.ftp.FTPClient;



public class MVSSpool {


    private FTPClient ftp = null;
    private String fUserId,fPassword,fHost,fJobPerfix,replyText;

    public MVSSpool(String fUserId, String fPassword,
            String fHost, String fJobPerfix) {


        this.fUserId = fUserId;
        this.fPassword = fPassword;
        this.fHost = fHost;
        this.fJobPerfix = fJobPerfix;
        ftp = new FTPClient();
    }



    public String getfUserId() {
        return fUserId;
    }

    public void setfUserId(String fUserId) {
        this.fUserId = fUserId;
    }



    public void setfPassword(String fPassword) {
        this.fPassword = fPassword;
    }

    public String getfHost() {
        return fHost;
    }

    public void setfHost(String fHost) {
        this.fHost = fHost;
    }

    public String getfJobPerfix() {
        return fJobPerfix;
    }

    public void setfJobPerfix(String fJobPerfix) {
        this.fJobPerfix = fJobPerfix;
    }





    public void submitJobToSpool(String jobName) throws Exception{

        if (jobName != null){



            connectMVSFtp();
            InputStream is = null;
            BufferedReader br = null;
            String currentLine = null;
            try{
                ftp.retrieveFileStream("'"+jobName.trim()+"'");

                replyText = ftp.getReplyString();
                System.out.println("some " + replyText);

                String[] replies = ftp.getReplyStrings();
                String remoteFileName = replies[replies.length - 1].split(" ")[2]+ ".2";


                for(String rep :replies){

                    System.out.println("checking .. " + rep);
                }

                Thread.sleep(10000);

                System.out.println("getting sysout of the file " + remoteFileName);

                is = ftp.retrieveFileStream(remoteFileName);
                replies = ftp.getReplyStrings();
                for(String rep :replies){

                    System.out.println("checking 2 .. " + rep);
                }

                if (is != null){

                    br = new BufferedReader(new InputStreamReader(is));


                    while((currentLine = br.readLine()) != null){

                        System.out.println(currentLine);
                    }

                }

                ftp.completePendingCommand();

                System.out.println("Done...");
            }catch(Exception e){
                e.printStackTrace();
                throw new Exception("Error in submitting Job  from spool");
            }finally{
                ftp.disconnect();

                if(br != null){
                    br.close();
                }
                if(is != null){
                    is.close();
                }
            }


        }
    }

    /**
     * @throws SocketException
     * @throws IOException
     */
    private void connectMVSFtp() throws SocketException, IOException {

        // check if the required parameters are set already
        if (fUserId == null | fPassword == null | fHost == null){

        }else{
            ftp.connect(fHost);

            replyText = ftp.getReplyString();
            System.out.println(replyText);

            // login using user name and password

            ftp.login(fUserId, fPassword);
            replyText = ftp.getReplyString();
            System.out.println(replyText);

            // point the FTP to JES spool
            ftp.site("filetype=jes");
            replyText = ftp.getReplyString();
            System.out.println(replyText);
        }
    }


}

I am getting below messages

230 XXXXX is logged on. Working directory is "XXXXX.".

200 SITE command was accepted

some 125-Submitting job 'XXXXX.XXXX.JCLLIB(ALIAS)' FIXrecfm 80 125 When JOB07591 is done, will retrieve its output

checking .. 125-Submitting job 'XXXXX.XXXX.JCLLIB(ALIAS)' FIXrecfm 80 checking .. 125 When JOB07591 is done, will retrieve its output getting sysout of the file JOB07591.2 checking 2 .. 550 No spool files available for JOB07591, JesPutGet aborted Done...enter code here

amar
  • 11
  • 1
  • is it possible that the job has not completed when you go to get the job log? – SaggingRufus Mar 28 '17 at 13:20
  • Also, in the IBM Documentation, it does say that this error can occur if the JESINTERFACELEVEL is not set to 2 – SaggingRufus Mar 28 '17 at 13:22
  • I checked the job completed. also I see same error if I hard code the job id from previous run and try to get jeslog. and JESINTERFACELEVEL is set to 1 in FTP config in Mainframe. But I read I can get job details of the jobs that I submitted by my id even if JESINTERFACELEVEL is 1 – amar Mar 28 '17 at 16:26
  • I found the issue. I need to have MSGCLASS=H in my JCL in order to be able to pull if JESINTERFACELEVEL is 1 .http://www-01.ibm.com/support/docview.wss?uid=swg21294742 – amar Mar 28 '17 at 18:04

0 Answers0