× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Hi.

If you use the RJob class instead of the Job class you are able to get the 
Completion status of the job.
Updating values in the current job object can be done using the following 
code:

        job.loadInformation();  //When using the Job class and
        m_job.refreshAttributeValues(); //When using the RJob class

(String) m_job.getAttributeValue(RJob.COMPLETION_STATUS)
Returns 0 when completing normally and 1 when abnormal.

Sandeep Sakhawalkar
In the original posting you say your job never ends, which is correct 
because the job you monitor is your own command processing server job, 
which will be active for as long as you monitor is running.  I assume that 
the job you want to monitor is the submitted job.
If this is correct you need to get the job attributes for the submitted 
job, which can be done i several ways. Here is one example:
By analyzing the return messages from the command you can fin the job 
attributes. MessageID CPC1221 contains what you're after

AS400Message[] messagelist = m_command.getMessageList();
for (int i = 0; i < messagelist.length; ++i) {
        String data = new String(messagelist[i].getSubstitutionData());
        String msgID = new String(messagelist[i].getID());
        System.out.println("Msg : " + messagelist[i].getText());
        System.out.println("MsgId : " + messagelist[i].getID());
        if (msgID.equalsIgnoreCase("CPC1221")) {
                StringTokenizer meld =
                        new StringTokenizer(messagelist[i].getText(), " /"
);
                String[] melding = new String[meld.countTokens()];
                for (int j = 0; j < melding.length; j++) {
                        melding[j] = meld.nextToken();
                        if (melding[j].equalsIgnoreCase(jobname)) {
                                jobuser = melding[j - 1];
                                jobnumber = melding[j - 2];
                                break;
                        }
                }
        }
}
RJob m_job = new RJob(system, jobname, jobuser, jobnumber);

HTH

Regards, Rune




Ashish Kulkarni <kulkarni_ash1312@xxxxxxxxx>
Sent by: java400-l-bounces@xxxxxxxxxxxx
09.12.2003 14:35
Please respond to Java Programming on and around the iSeries / AS400 
 
        To:     Java Programming on and around the iSeries / AS400 
<java400-l@xxxxxxxxxxxx>
        cc: 
        Subject:        Re: job status is always active


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/
_______________________________________________
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.



As an Amazon Associate we earn from qualifying purchases.

This thread ...

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.