MONITOR FOR HELD LOCKS

25 pts.
Tags:
CL Program
CL programming
WRKOBJLCK
I created this pgm to check if a file is being locked. I would like to trap if there is a hold lock. If I can I would like to loop back if there is a hold until the hold is released. WRKOBJLCK OBJ(MCPARMS) OBJTYPE(*FILE) MONMSG MSGID(CPF9898) EXEC(PARMLCK: SNDUSRMSG + MSG('File MCPARMS in Library IBCFLPROD + not locked.') VALUES(C G) DFT(C) + MSGTYPE(*INQ) TOUSR(*REQUESTER) + MSGRPY(&REPLY)) DSPMSG MSGQ(*WRKSTN) Thank you Vince J.

Answer Wiki

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

Hi Vince01
Would something like this work? Try for 30 seconds if not available wait 30 seconds and repeat
LOOP:
ALCOBJ OBJ((QDDSSRC *FILE *EXCL)) WAIT(30)
MONMSG MSGID(CPF1002) EXEC(DO)
DLYJOB (30)
GOTO LOOP
ENDDO

DLCOBJ OBJ((QDDSSRC *FILE *EXCL))

MSG(‘File MCPARMS in Library IBCFLPROD +
not locked.’) VALUES(C G) DFT(C) +
MSGTYPE(*INQ) TOUSR(*REQUESTER) +
MSGRPY(&REPLY))
DSPMSG MSGQ(*WRKSTN)

Phil

– – – – – – – – – – – – – – – –

You may care to add a countdown loop into that, to be sure of an exit.

You could use the API to extract details of the locks, and message the ‘locker’, or add to your own message the ID of the user/job which is holding the object.
When you find out what’s holding it, go to the code and change it. There aren’t many things which need a long time lock on an iSeries. If the lock is there to keep people out of something, then you’ll need a generic solution, as you’re really using the object lock as a security feature.

Yorkshireman

– – – – – – – – – – – – -

Discuss This Question: 3  Replies

 
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