using the monitor opcode to loop on a locked
dataarea until the lock is released or until
the cows come home
dataarea until the lock is released or until
the cows come home
PHP Code:
//
d alreadylocked s n
d cmdstring s 256
d cmdlength s 15 5
d somefield s 5 0
D Locked C 00202
//
// external calls
//
d $command pr extpgm('QCMDEXC')
d command 256
d Length 15 5
/Free
//--------------------------------------------------------
// MAIN PROGRAM
//--------------------------------------------------------
cmdstring = 'ALCOBJ OBJ((LBIFIL/BRC01LOCK *DTAARA *EXCL))';
cmdlength = %len(%trim(cmdstring));
dou Alreadylocked = *off;
monitor;
AlreadyLocked = *off;
$command(cmdstring: cmdlength);
On-error Locked;
somefield = %Status;
AlreadyLocked = *on;
endmon;
enddo;
*inlr = *on;
/End-Free
Comment