× 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, Bob:

I think this is a rather "poor design" regardless of how that "loop" is coded ... for the following reasons:

* what happens if the batch job fails or aborts, and so never resets
the data area?
o (the interactive users will be stuck waiting forever ...)
* a loop like this needlessly ties up the user's interactive session ...
o perhaps it would be better to check the condition and then
notify the user to "Try again later..."

A few related questions may help to point to a better design:

* what is the nature of this batch job? Is it updating some "critical
resources" such as some file(s)?
* what is the nature of the program that is to run interactively, and
why can it not run while that batch job is active?

SUGGESTION
============
Instead of setting a flag value in that data area, you could use that data area as a "semaphore" (a resource that can be locked) and have the batch job allocate the *DTAARA for *EXCLusive use ... Then, the interactive CL program can attempt to issue ALCOBJ against that same data area, also trying to gain *EXCLusive use, and specify "no wait" and if it fails to allocate, you can monitor for that message with a MONMSG, and then notify the user to "please try again later" ... if more than one interactive user is allowed to run this interactive process at the same time, then you would want to immediately issue a DLCOBJ to de-allocate the lock on that data area, when the lock has been obtained.

The main benefit of this approach is that, when the batch job ends, normally or abnormally, the exclusive lock will be released.

Hope that helps,

Mark S. Waterbury

> On 5/18/2016 2:45 PM, Bob Cagle wrote:
This is more of a CL programming question:

Background: I have an interactive program that I need to have NOT run while a specific batch job is running. Currently the batch job updates a data area with a flag at the start of the job and then clears it at the end. Interactive jobs can then check for this flag before running.

I have this code in my CL:

CHECK:
/* Check data area to see if job is running */
Rtvdtaara DataArea rtnvar(&Check)
If (&Check = '1') then( DO )

/* wait 30 seconds and then try again */
Dlyjob dly(30)
Goto CHECK
ENDDO


The GOTO is bothering me, so the question is - would you code this different? This seems simple and straight-forward, but in your opinion is there a better way?

Thanks

Bob Cagle
IT Manager
Lynk



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.