Problem : CL – CHKRCDLCK command on as/400 i series

Problem : CL – CHKRCDLCK command on as/400 i series

Hello ,

Could someone please provide me with some background information (or a place where I can find it) on the CHKRCDLCK (check for record lock) command (CL language) on an as/400 i series platform?  I am relatively new to the CL language and have not been able to find much about this.

Particularly, I am looking for the syntax of this command and how it handles/throws any errors.

Thanks!


Solution : CL – CHKRCDLCK command on as/400 i series

my six pence worth…

I would go with the exclusive ALCOBJ,

in your CL you would code something like…
…………….
ALCOBJ OBJ((&LIB/&OBJ &TYPE *EXCL &MEMBER))
/* Monitor for any error – unable to allocate object – still being written to */
MONMSG CPF0000 EXEC(DO)
DLYJOB  (120)     /* delay job for 120 seconds (=2 mins) */
GOTO LOOP
ENDDO
……………..

The MONMSG CPF0000 traps any error message, if you wish you could add speciifc messages.
Look at the extended help for any command and you should find a list of errors you can monitor for….  in ALCOBJ these are…
CPF1002     Cannot allocate object &1.
CPF1040     Maximum number of objects allocated on system.
CPF1085     Objects not allocated.

So you could if you wanted…

……………………
ALCOBJ OBJ((&LIB/&OBJ &TYPE *EXCL &MEMBER))
/* monitor for certain messages to do one thing */
MONMSG (CPF1002 CPF1085) EXEC(DO)
DLYJOB  (120)     /* delay job for 120 seconds */
GOTO LOOP
ENDDO
/* monitor for certain messages to do another thing */
MONMSG CPF1040 EXEC(DO)
SNDUSRMSG MSG(‘Message Text’) TOMSGQ(*SYSOPR)
GOTO SOMEWHERE
ENDDO
/* monitor for ALL other error messages to do another thing */
MONMSG CPF0000 EXEC(DO)
SNDUSRMSG MSG(‘Some General Error has happended’) TOMSGQ(*SYSOPR)
GOTO SOMEWHEREELSE
ENDDO
…………………….

You can also program a MONMSG CPF0000 without an EXEC parameter, this ignores any specified errors and continues processing with the next statement.