JobsThe AS/400 Toolbox for Java jobs classes allow a Java program retrieve the attributes of a job and list the active jobs. The job classes are as follows:
Using the jobs classes causes the AS400 object to connect to the AS/400. See managing connections for information on managing connections. JobListYou can use JobList class to list AS/400 jobs. With the JobList class, you can retrieve the following:
Use the getJobs() method to return a list of AS/400 jobs. The following example lists all active jobs on the system: |
// Create an AS400 object. List the // jobs on this AS/400. AS400 sys = new AS400("mySystem.myCompany.com"); // Create the job list object. JobList jobList = new JobList(sys); // Get the list of active jobs. Enumeration list = jobList.getJobs(); // For each active job on the system // print job information. while (list.hasMoreElements()) { Job j = (Job) list.nextElement(); System.out.println(j.getName() + "." + j.getUser() + "." + j.getNumber()); }
JobLogYou can use the JobLog class to retrieve messages in the job log of an AS/400 job. Do this by calling getMessages(). The following example prints all messages in the job log for the specified user: |
// ... Setup work to create an AS400 // object and a jobList object has // already been done // Get the list of active jobs on // the AS/400 Enumeration list = jobList.getJobs(); // Look through the list to find a // job for the specified user. while (list.hasMoreElements()) { Job j = (Job) list.nextElement(); if (j.getUser().trim().equalsIgnoreCase(userID)) { // A job matching the current user // was found. Create a job log // object for this job. JobLog jlog = new JobLog(system, j.getName(), j.getUser(), j.getNumber()); // Enumerate the messages in the job // log then print them. Enumeration messageList = jlog.getMessages(); while (messageList.hasMoreElements()) { AS400Message message = (AS400Message) messageList.nextElement(); System.out.println(message.getText()); } } }
ExamplesList the jobs belonging to a specific user and list jobs with job status information. Display the messages in a job log.
[ Legal | AS/400 Glossary ] |