Class Job

  • All Implemented Interfaces:

    public class Job
    extends Object
    implements Serializable
    Represents a job on the IBM i server. In order to access a job, the system and either the job name, user name, and job number or internal job identifier need to be set. A valid and sufficient combination of these must be set before getting or setting any of the job's attributes.

    Some of the attributes have associated 'get' and 'set' methods defined in this class. These are provided for backwards compatibility with previous versions of the IBM Toolbox for Java. The complete set of attribute values can be accessed using the public constants.

    Note: Most of the 'get' methods will either go to the system to retrieve the job attribute value, or will return a cached value if the attribute was previously retrieved or previously set by setValue() or one of the other 'set' methods. Use loadInformation() to refresh the attribute values from the system.
    For example:

      Job job = new Job(system, jobName, userName, jobNumber);
      while (job.getStatus().equals(Job.JOB_STATUS_ACTIVE))
          // Wait a while.
          // Refresh the attribute values.
      System.out.println("Job status is: " + job.getStatus());

    Note: Jobs created by SBMJOB tend to get cleaned-up immediately upon job completion (if no spooled files were created); whereupon getStatus(), getCompletionStatus(), and most other 'get' methods will throw an AS400Exception containing an AS400Message indicating "Internal job identifier no longer valid" (message ID CPF3C52). That exception should be interpreted as an indication that the job has completed.

    Note: To obtain information about the job in which a program or command runs, do something like the following:

      AS400 system = new AS400();
      ProgramCall pgm = new ProgramCall(system);
      pgm.setThreadSafe(true);  // Indicates that the program is to be run on-thread.
      String jobNumber = pgm.getServerJob().getNumber();
    (If the program or command is not to be run on-thread, omit the setThreadSafe() call.)
    See Also:
    JobList, CommandCall.getServerJob(), ProgramCall.getServerJob(), Serialized Form