


To keep a process from running twice I've seen it lock a data area .. it could just lock the program to prevent it from being run a second time while it's running.
WRKOBJLCK or is it DSPOBJLCK should show the lock state of the program and the job(s) that have it locked. Why do I think he/she is really encountering a lock on a display file and not the program at all?
Phil
If the program is interactive and uses a display file, you can check for the locks on the display file..
Otherwise, no easy way of doing it other than going through the call stacks of all jobs on the system (I wouldn’t recommend that)


The first answer is “Nobody has it locked.” It’s almost certain that you’ll never see a lock established on a program. Even if you do set a lock on a program, it won’t slow anyone down who tries to run the program.
The second answer is “It doesn’t matter.” If you have created the application correctly, then you can recompile while the program is in use. No one should notice.
Where it can become a problem is when PGMA calls PGMB.
If you recompile PGMA while the user’s job is actually processing in PGMB, the return from PGMB back to PGMA can fail. However, it’s not easy actually to make it happen… at least, not if you allow the system to manage the replacement of old program objects with new ones. If you are manually deleting program objects before you start the compilation of the replacement, you are on your own.
In any case, the only way you can tell if any user is running a program is to retrieve the call stack of every user job in the system to see if your program is in the stack of any of them. The biggest problem will be that call stacks change so fast that the call stack of the first job may be different by the time you start looking through the second job. Obviously, by the time you get all the way through all jobs, you’ll have to go back and start over again because many call stacks will already be obsolete.
Tom
Is the program called by a db2 trigger?
Phil
…a db2 trigger?
That can get even more interesting when host server jobs are involved.
Tom
Yes, but we’re lacking response from the person who asked the question.
Phil
That’s why I added my comment, as a kind of ‘ping’ for the OP. Sooner or later, a question will be asked where a comment will get some attention. (I’m something of an idealist, I suppose.)
Might as well talk amongst ourselves…
Tom
The prizes should be for asking a question and then working with the “experts” to actully solve the problem and then acknowledging the solution.
I understood the question as being about concern over recompiling a program that is in use. When standard developer’s functions are used, the manipulation of the old object into QRPLOBJ makes things fairly easy.
Most of us are used to it, though the process itself is often unfamiliar. If it isn’t known at all to a developer, it can be pretty confusing.
Tom
it could just lock the program…
That’s what I’ve done for many years. It works fine for simple lock tests and it doesn’t actually interfere with anything. It also doesn’t require an extra object just for the purpose.
Tom
The WRKOBJLCK
Is what I needed to show me who is in the File.
Thanks
I completely agree, Philpl1jb…once the answer is resolved, the person who provided the answer and the person who asked the question will receive points for the “accepted answer” that may lead to a tangible prize.
So realistically, that’s exactly how the site works–as long as the question is completed.
…Is what I needed to show me who is in the File.
Glad you found an answer. Note that a lock on a “file” has an effect very different from a lock on the “program”, and the question asked about a “program” that was locked — the question left much to interpretation. Dialog could have gotten to the answer quickly.
Tom
EmNichs
I didn’t answer this question, I think TomLiota and Adamwhiuk2002 seem to have gotten it while I, unfortunately, read the question in a way that mislead with some interesting but somewhat useless results.
When people ask questions they rarely hang in there to help us sort out the question and alternative solutions. They are often one-time on the board, creating a profile on the fly, asking a question, and probably using a bogus e-mail. It’s such a waste.
Phil
Can’t figure out why someone would ask how to tell who has a program locked when they really want to know who has a file locked. You all did a great job of cutting through the fog, but as Tom said, properly asked, the question would have been promptly and accurately answered. A minimal amount of care when posting the question would have saved this discussion from itself.