× 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.




Hello Sriram,

Since your question has nothing to do with RPG, I'm replying to the MIDRANGE-L mailing list, but I've CC:ed you directly in case you're not subscribed to it.

I have a cl prog with multiple sbmjob commands, where in I need to make sure
that one job on the list is completed successfully and run the other job.
Please anybody can guide on that.

There are several solutions, the best one will depend on your exact requirements:

a) A job queue can be created so that only one job will be run at a time. When you submit jobs to the queue, it'll queue them all up, but it won't start the 2nd one until the first one has completed. And it won't start the 3rd one until the 2nd one has completed, and so on... This is the traditional solution, and the one that I'd recommend for you at this point.

b) When you use SBMJOB, there's a MSGQ parameter that specifies where messages about the job starting up, completing, and any error messages get sent to. You can easily set this message queue to something that you've created for this application, and write a program that submits one job, waits on the message queue for the completion message, then submits another job, etc. The advantage to this approach is that you can determine if the job was successful, or whether it ended in error, and you can use that to determine whether the next job should be submitted or not.

c) If you want all of the jobs to be submitted and running at once, and to only stop and wait if they absolutely HAVE TO wait, then you can use object locks. Have the first program that needs to use a particular file allocate that file (with the ALCOBJ command) and have the other ones wait until that object is available (also using ALCOBJ). That way, any preliminary work can be done, and they can stop and wait only when they need the file. This can improve performance in some circumstances, but does require careful planning.

d) There's also an API that can be used to check the status of a job. When a job is submitted, it sends you back a message that contains the job name/user/number of the newly created job. You can take this info and call an API to check the status of the job. You can do that periodically if you want to verify that a job completed successfully.

e) Data queues make a great way to synchronize activity between jobs as well. Jobs can use data queues to send messages to each other, and to wait for messages to appear. When a job starts, it can send a message to the queue that says "I've started". When it completes a particular task, such as updating a file, it can send a message saying "File Updated". Other jobs can wait on these messages. It can also send a message when it completes, and you can wait for that message so that you know that the job is done.

So there are tons of possibilities for what you want to do, and most of them are pretty simple.

Good luck


As an Amazon Associate we earn from qualifying purchases.

This thread ...


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.