Created On:  19 October 2011


When testing the record lock behavior in a Visual COBOL application that is accessing RM/COBOL indexed files, I find that the behavior is different than that of RM/COBOL.  In RM/COBOL when I try to access a record that is currently locked by another program, the read will wait until the lock is released before returning to the program.

In Visual COBOL accessing a locked record returns immediately with a locked record file status.  How can I change this behavior?


You can change this behavior so that it works like the default RM/COBOL behavior by using the RM directive in addition to the CALLFH("ACUFH") directive to compile the program.  Then if a locked record is attempted to be read in a second program it will automatically wait until the record is released by the program holding the lock.

You can also use the RETRYLOCK directive instead of the RM directive if you only wanted to turn on this locking behavior without changing other behavior associated with the RM directive.