Need to know whether a job is completed

25 pts.
Tags:
AS/400 jobs
Hi,

I need to submit 2 jobs JOB 1 and JOB2 but before doing a sbmjob on JOB2 i should make sure that JOB 1 has ended. How can i do that during program execution.

Thanks.

Answer Wiki

Thanks. We'll let you know when a new response is added.

The easiest way is to submit them at the same time to a job queue that is single thread.
If all you job queues allow multiple jobs running at the same time, you can set one of the priority levels in the job queue to be single thread.
==
Another option is to submit job2 from job1.
==
There are many other ways, but they are not as straight forward.
Let us know if the above options will not work for you and we can put out more ideas.

=====================================================

Assuming JobA wants to submit JobB, and then submit JobC after JobB finishes —

The SBMJOB JOB( JOBB ) command will cause a CPC1221 *COMP message to be sent to the program in JobA. That completion message can be received and info about JobB can be extracted from it. The fully-qualified name of JobB is particularly useful.

Also, there is a SBMJOB MSGQ() parameter that tells the name of the message queue that you want messages about JobB to be sent. When JobB finishes, a CPF1241 completion message will be sent to that message queue telling about how JobB ended. The default parameter value is SBMJOB MSGQ( *USRPRF ). I.e., a message will be sent to the user profile message queue for whichever user submitted the job. When you run a SBMJOB command, you should see a message in your message queue when the job ends — try it.

You can name any message queue you choose on the MSGQ() parameter.

So, the CPC1221 gives you the fully-qualified job name. You can use that to retrieve the status of the job at any time.

And the MSGQ() gives something you can monitor for, like a signal. When a message arrives on the queue, you can receive it and decide what action to take next, e.g., submit JobC.

Tom

Discuss This Question:  

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following