|
On 18/11/2006, at 12:25 AM, Charles St-Laurent wrote:
I try to use the QUSRJOBI API to know when a submmited job ends. I did a RPGLE program that interfaces the API as an external program. Then I call myRPG program like that: 1) I do my SBMJOB2) I do a RCVMSG MSGTYPE(*ANY) MSGDTA(&MSGDTA) MSGID(&MSGID) to know thefull qualified name of the job I want to verify.3) I call my RPG program with the jobname, the job user and the job id Iretrieved previously from &MSGDTAThe first time I call my RPG program, everything works fine as the job is in the JOBQ. But when the job begins (Status Code = *Running), it seems that the OS gives a new Job ID to my submited job. My RPG program no longer seemy first job, so it returns the status code "Job Not Found".I tried to reference the submited job with its internal job id. The first time I call my RPG program, I call it with the full qualified job name and ablank internal job id. The subsequent calls to my RPG uses the filledinternal job id, jobname = "*INT" and the rest of the full qualified nameequals to blanks... I believed that this internal id was unique and invariant, even if the job id changes when the job is running... I wonder what am I doing wrong... Any suggestion?
First point: The system does not change the qualified name of the job or the internal ID during the life of the job. So if the API says the job is not found it can only because of two things:
1) The job no longer exists2) Your code messes up the parameters on the subsequent calls to the API
Second point: If a job ends without creating any spooled files the job is gone.
So presuming your code is correct the most likely cause is that the submitted job does not create any spooled output and it runs for a very short time interval. On the first call to QUSRJOBI the submitted job is found on the job queue but by the time you call the API again the job has completed, has no spooled output, and is gone from the system.
It appears you don't want the main program to continue until the submitted job has completed. If the job is not found then you know it has completed. However, given that you are already receiving the message to give the qualified job name you might find it easier to do the following:
1) SBMJOB ... MSGQ(some-lib/job-name) 2) RCVMSG MSGQ(some-lib/job-name) WAIT(*MAX) RMV(*YES) MSGID(&MSGID)3) If &MSGID is CPF1241 the job ended normally. If CPF1240 the ended abnormally.
4) Continue with normal operation Regards, Simon Coulter. -------------------------------------------------------------------- FlyByNight Software AS/400 Technical Specialists http://www.flybynight.com.au/ Phone: +61 3 9419 0175 Mobile: +61 0411 091 400 /"\ Fax: +61 3 9419 0175 \ / X ASCII Ribbon campaign against HTML E-Mail / \ --------------------------------------------------------------------
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2025 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.