System Lock File Requirements
It should be an indexed file with the lock mode set to manual:
SELECT LOCK-FILE
ASSIGN TO RANDOM SYLCKFIL-PATH
ORGANIZATION IS INDEXED
ACCESS MODE IS DYNAMIC
LOCK MODE IS MANUAL
RECORD KEY IS LOCK-KEY
FILE STATUS IS LOCK-FILE-STATUS.
ASSIGN TO RANDOM SYLCKFIL-PATH
ORGANIZATION IS INDEXED
ACCESS MODE IS DYNAMIC
LOCK MODE IS MANUAL
RECORD KEY IS LOCK-KEY
FILE STATUS IS LOCK-FILE-STATUS.
The declarative should be coded like the following example so the application code can intercept a lock condition and give the user the appropriate error message:
LOCK-FILE-ERROR SECTION.
USE AFTER STANDARD ERROR PROCEDURE ON
LOCK-FILE.
USE AFTER STANDARD ERROR PROCEDURE ON
LOCK-FILE.
Notice that there is no error procedure.
To lock the file exclusively, the file should be opened I-O with lock. This is the same as using LOCK MODE IS EXCLUSIVE in the Select statement.
OPEN-LOCK-FILE-WITH-LOCK.
PERFORM GET-PATH.
MOVE PASSING-DATA-PATH TO SYLCKFIL-PATH.
OPEN I-O LOCK-FILE WITH LOCK.
PERFORM GET-PATH.
MOVE PASSING-DATA-PATH TO SYLCKFIL-PATH.
OPEN I-O LOCK-FILE WITH LOCK.
The file naming convention must be ??LCK??? and the length of the record must be 24 bytes for the file handler to recognize that a lock file is being processed.
CLS