How to Get IBM i Job details Using Job Number - Ja

2019-08-16 08:02发布

I want to get IBM i job details using that job number. i get all job list. but i want to get job details using it's job no. Please help me friends.

Edit: I believe the question is 'How can I get job details given a fully qualified job name?'

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条回答
SAY GOODBYE
2楼-- · 2019-08-16 08:27

You can do it different ways. You can ask JT400 to return the specific job you are looking for, or you can ask JT400 to subset the list of jobs. Here is an example of both:

    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);
    }

}
查看更多
登录 后发表回答