如何使用作业号获取IBM i作业详细信息 - Java(JT400)

时间:2013-05-03 13:21:08

标签: java ibm-midrange jt400

我想使用该职位编号获取IBM i职位详细信息。我得到了所有的工作清单。但是我想用工作来获取工作细节。请帮帮我朋友。

编辑:我认为问题是“如果获得完全合格的工作名称,我怎样才能获得工作细节?”

try {
AS400 system = new AS400 ("SERVER","USER", "PASS");
JobList jobList = new JobList(system);
Enumeration list = jobList.getJobs();
while (list.hasMoreElements())  {
     Job  j= (Job) list.nextElement();
     String GCPU = Integer.toString(j.getCPUUsed());
     System.out.println("Name " + j.getName() + " | Job NO : " + j.getNumber() + " | User : " + j.getUser() + " | CPU USED : " + j.getCPUUsed());

}
 } catch (Exception e) {
     System.out.println(e);
 }

1 个答案:

答案 0 :(得分:3)

你可以采用不同的方式。您可以要求JT400返回您要查找的特定作业,或者您可以要求JT400将作业列表分组。以下是两者的示例:

    public static void main(String[] args) {

    String systemName = "my_system_name";
    String jobName = "job_name";
    String userName = "user_name";
    String jobNumber = "job_number";

try {
    AS400 system = new AS400 (systemName);

    // Get this specific job
    Job job = new Job(system, jobName, userName, jobNumber);
    System.out.println("Name " + job.getName() + " | Job NO : " + job.getNumber() + " | User : " + job.getUser() + " | CPU USED : " + job.getCPUUsed());

    // Create a list and subset it
    JobList jobList = new JobList(system);
    jobList.clearJobSelectionCriteria();
    jobList.addJobSelectionCriteria(JobList.SELECTION_JOB_NUMBER, jobNumber);
    Enumeration list = jobList.getJobs();
    while (list.hasMoreElements())  {
        Job  j= (Job) list.nextElement();
        String GCPU = Integer.toString(j.getCPUUsed());
        System.out.println("Name " + j.getName() + " | Job NO : " + j.getNumber() + " | User : " + j.getUser() + " | CPU USED : " + j.getCPUUsed());
        }

    } catch (Exception e) {
        System.out.println(e);
    }

}