I have a program that allocates an object (*file), calls a program, then deallocates. The dlcobj does not work. RPG PROGA calls CL PROGB which calls CL PROGC. PROGC does the alcobj and dlcobj. However when the program returns to PROGA (interactive RPG), the object is still locked. Any ideas?
It is possible to have multiple locks on the same object, both different types of locks (*SHRUPD, *EXCL) and the same type of lock (*SHRRD 5 times). Each lock needs to be deallocated.
I suspect what you are doing here is that the CL gets an *EXCL lock, then the RPG opens the file, and in doing so gets an implied lock (probably *SHRUPD or *SHRRD), then the CL releases its *EXCL lock but you are left with the implied lock because the file is still open in the RPG.
a) Check how many and what type of lock you have while still inside WSCHSTSR,
b) Try having WSCHSTSR close the file before it returns.
Ok, I found the issue. The program that was locking the file bombed and the session it ran from was still active. I had to look at the job log to figure it out. Thanks everyone for your help!!!
Discuss This Question: 5  Replies
Here's the code:
ALCOBJ OBJ((LOCKPGMP *FILE *EXCL)) WAIT(120)
CALL WSCHKSTSR (&pgm &plock &pcheck &plocked)
DLCOBJ OBJ((LOCKPGMP *FILE *EXCL))