Hi

Always build a new object of Job before getting the
status
Some how job is not updated to reflect current job
status
So in your while loop, create a instance of job before
getting the status
this is my code
which works fine for me
 Job myJob = new Job(as400, jobNumber, jobUser,
newJobNum);
 runStatus = (String)
myJob.getValue(Job.ACTIVE_JOB_STATUS);
 while (runStatus != null &&
(runStatus.equals(Job.ACTIVE_JOB_STATUS_RUNNING)
                                     ||
runStatus.equals(Job.ACTIVE_JOB_STATUS_WAIT_TIME_INTERVAL)
                                     ||
runStatus.equals(Job.ACTIVE_JOB_STATUS_NONE)))
        {
          try
          {
            myJob = new Job(as400, jobNumber, jobUser,
newJobNum);
            runStatus = (String)
myJob.getValue(Job.ACTIVE_JOB_STATUS);
}
 catch (AS400Exception exc)
          {
}
}

--- Sandeep Sakhawalkar
<Sandeep.Sakhawalkar@xxxxxxxxxxxxxxxxx> wrote:
> In the following program, I am noticing that the job
> status stays ACTIVE and
> does not change.
> 
> My question is what should I check in order to see
> if the job has completed
> successfully or errored out ? 
> 
> Please help.
> 
> Thanks
> Sandeep
> 
> **************** AS400Test.java ***************
> 
> import com.ibm.as400.access.*;
> import com.ibm.as400.security.auth.*;
> import java.io.*;
> import java.util.*;
> 
> public class AS400Test
> {
>       public static void main(String[] args)
>       {
>               AS400 system = null;
>               try
>               {
>                       system = new AS400("SYSTEMNAME", "UserName",
> "Password");
>                       system.connectService(AS400.COMMAND);
>                       CommandCall m_command   = new CommandCall(system);
>                       if (m_command.run("SBMJOB JOB(TESJOB)
> CMD(WRKSYSSTS)"))
>                               System.out.println("m_command.run is set to
> true");
>                       else
>                               System.out.println("m_command.run is set to
> false");
> 
>                       AS400Message[] messagelist =
> m_command.getMessageList();
>               for (int i = 0; i < messagelist.length;
> ++i)
>               {
>               System.out.println("MESSAGE IS : " +
> messagelist[i].getText());
>               }
> 
>                       Job m_job                       =
> m_command.getServerJob();
>                       String jobNumber        = m_job.getNumber();
>                       String jobstatus        = m_job.getStatus();
>                       String jobno            = m_job.getNumber();
>                       String jobtype          = m_job.getType();
>                       String jobuser          = m_job.getUser();
> 
>                       JobLog jl                       = m_job.getJobLog();
> 
>                       System.out.println("*** JOB INFORMATION*****" +
>                                                          " jobNumber : " +
> jobNumber   +
>                                                          " jobstatus : " +
> jobstatus   +
>                                                          " jobtype : "   +
> jobtype     +
>                                                          " jobuser : "   +
> jobuser
>                                                          //" internalJOBID
> : "   + internalID
>                                                         );
> 
>                       while (jl.getLength() <= 0)
>                       {
>                               System.out.println("Waiting for output");
>                       }
> 
>                       AS400Message msg        = null;
> 
>               Enumeration msglst = jl.getMessages();
> 
>                       while (msglst.hasMoreElements())
>                       {
>                               msg = (AS400Message) msglst.nextElement();
>                               System.out.println(msg.getText());
>                       }
> 
>                                    // STAYS IN THIS
> LOOP FOREVER
> 
>                       while
> (m_job.getStatus().equals(m_job.JOB_STATUS_ACTIVE))
>                       {
>                               Thread.sleep(10);
>                               System.out.println(jobno + " is in : " +
> m_job.getStatus());
>                       }
> 
>                       System.out.println(jobno + " has status of " +
> m_job.getStatus());
> 
> 
>                       system.disconnectAllServices();
>               }
>               catch (Exception e)
>               {
>                       e.printStackTrace();
>               }
>       }
> 
> }
> _______________________________________________
> This is the Java Programming on and around the
> iSeries / AS400 (JAVA400-L) mailing list
> To post a message email: JAVA400-L@xxxxxxxxxxxx
> To subscribe, unsubscribe, or change list options,
> visit:
> http://lists.midrange.com/mailman/listinfo/java400-l
> or email: JAVA400-L-request@xxxxxxxxxxxx
> Before posting, please take a moment to review the
> archives
> at http://archive.midrange.com/java400-l.
> 


__________________________________
Do you Yahoo!?
New Yahoo! Photos - easier uploading and sharing.
http://photos.yahoo.com/

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.