Adabas file in use

Re-posted from SAG-L:

Using Adabas utilities on an IBM mainframe, is there a way to set a non-zero return code if an Adabas file is in use. I’d like to execute this command;

ADADBS OPERCOM DFILES=077

and if file 077 is in use, get a non-zero return code from that job step.
Can this be done? Is there another adabas utility I can use to get the same result?

When I understood the question right, you want Adabas to set the jobs condition code to non-zero.
With the ADADBS utility you will receive a cond code 0 in the case the file is used and also if it is not used. This is because the function itself is correctly performed. The utilities set the cond code to 4 or 8 in the case that the required function cannot be performed (cond code 8 ), or if they want to notify the user that there is a warning (cond code 4).

What I can think of would be the possibility to run ADAULD with two parameters: NUMREC and UTYPE. ADAULD does normally open a file with EXU, if there are update users then ADAULD will get a rsp-48 and this will lead to an error and to cond code 8. You can use the parameter UTYPE to check also for read users. If there is no user active you certainly do not want to have a long running ADAULD to get the file locked for other users, NUMREC=1 should minimize the runtime.

I have no other ideas so far,

Best Regards,

Uschi

I noticed that when I run an ADADBS job with OPERCOM DFILES=?, when there are no users, DDDRUCK has 15 records. When there are users, DDRUCK has 17 records. I wonder if you could allocate DDRUCK with just enough space for 15 records, so you’ll have an error when the job tries to write 17 records. Maybe make it disp=mod so it will add records to the end of the file, which has enough roon allocated for 15 more records, but not enough for 17.