JobLog

The JobLog class (in the access package) retrieves messages in the job log of an AS/400 job by calling getMessages().

Begin changeNote: When possible, use a resource class instead of a class from the access package. Resource classes provide a generic framework and a consistent programming interface for working with various AS/400 objects and lists. The resource classes for working with jobs are RJob, RJobList, and RJobLog.End change

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

        }
     }