So, your nightly backup or other important job is running and BOOM, a message arrives on the QSYSOPR message queue that the job has encountered a record allocation or object allocation error, because some other job is holding a lock on the record or the object you need. You do a WRKOBJLCK (Work with Object Locks) command to see who has it, and send the offending user a message or terminate the offending job so the important job can run.
The following command will do all this for you. The Process Object Locks (PRCOBJLCK) command identifies all jobs currently holding a lock for the specified object. For each job, it either sends a break message or ends the job. The break message is sent to the jobs holding the lock or optionally to all jobs currently running under the user profile of the jobs holding the lock.
Note: To run this command, *JOBCTL special authority is required.
The command prompt is shown here:
Process Object Locks (PRCOBJLCK) Type choices, press Enter. Object . . . . . . . . . . . . . ________ Name Library . . . . . . . . . . . *LIBL Name, *LIBL, *CURLIB Object type . . . . . . . . . . _______ *ALL, *ALRTBL, *BNDDIR... Action to perform . . . . . . . *BRKMSG *BRKMSG, *ENDJOB Message text . . . . . . . . . . _______________________________________ __________________________________________________________________________ ___________________________________________________________________ Send message to . . . . . . . . *JOB *JOB, *USER How to end . . . . . . . . . . . *CNTRLD *CNTRLD, *IMMED Delay time, if *CNTRLD . . . . . 30 Seconds Ignore record lock . . . . . . . *NO *NO, *YES
The following source code comprises the command:
CBX944H PNLGRP Process Object Locks - HELP CBX944 RPGLE Process Object Locks - CPP CBX944X CMD Process Object Locks - Command
See each source member for compile instructions, and see the help panel group for additional documentation.
You can download a zip file containing all the source code here.