Return to the RPG Tips
Displaying Record-Lock Messages in RPG
When a user tries to update a record being held for update by another job, an error occurs. (The record wait default value is 60 seconds, so it often literally takes a minute before the error is detected.) You can capture this error and display the name of the user who caused the record lock so that the user being inconvenienced can solve the problem herself instead of calling you. The sample I- and C-specs below illustrate this technique: I SDS I 91 170 MSGTXT . . . C KEY CHAINFILE 9990 C *IN90 IFEQ '1' C MOVELMSGTXT ERRMSG C END On the CHAIN operation, put an indicator in columns 56 and 57 to capture the record allocation error. If the indicator comes on, retrieve the error message text from positions 91 through 170 of the program status data structure (PSDS). The message will say "Record &REC# in use by job &JOBNO/&USER/&JOBNAME." If that message is too cryptic for your users, you can write a program to pull the user name from the message and display it in a more understandable error message. Your users can then ask the user causing the lock to release the record. by Bryan Meyers
[report a broken link by clicking here]