I have a program that reads through FILEA for update and when it finds a record in FILEA that is locked by another program, I want it to display the RRN of the locked record along with an error message. Problem is the RR# in the INFDS for FILEA only updates the RR# in the DS of the last record that was successfully read. How can I capture the RRN of the record in FILEA that the program is trying to retrieve but is locked.
Announcement
Collapse
No announcement yet.
Capturing the rrn of a locked record
Collapse
X
-
I would modify Birgitta's suggestion to test for the lock condition and if encountered try a chain(n) or read(n) to get the record.
That said I'm frankly not sure why you want the RRN because it is pretty meaningless in most cases - why not just display the key of the record and (more usefully) interrogate the lock and find out what program/user is holding it.
Once you establish which program fix it so that it never holds locks while a record is displayed to the user - which situation probably accounts for about 90+% of all record lock scenarios.
Comment
-
-
The error message in the PSDS has the RRN of the locked record.
Try this program, changing "myfile" to some file that has at least two records.
Code:dcl-f myfile usage(*update) infds(infds); dcl-ds infds; msgid char(7) pos(46); end-ds; dcl-ds sds psds; exception_data char(80) pos(91); end-ds; read(e) myfile; // read one record read(e) myfile; // read another record if %error(); dsply 'Error. Check joblog for msg about infds, psds'; snd-msg msgid + ' "' + exception_data + '"'; endif; dsply 'wait, type 1' '' *in10; *inlr = '1';
- Submit a call to the program to batch to lock the second record
- OVRDBF myfile waitrcd(1)
- Call it from your interactive job
- If the DSPLY says an error occurred, dspjoblog to see the SND-MSG output
- WRKSBMJOB and use option 7 to reply to the DSPLY for the submitted call
Code:CPF5027 "Record 2 in use by job or transaction 873132/BMORRIS/BMORRIS.
Comment
Comment