Is there any way I can test a logical from within a CL program to see if it is currently being rebuilt. I guess...
what I am after is a way of simulating EDTRBDAP from within a CL program.
I can't think of a direct method of doing it, but there is an indirect. It is possible to use DSPFD on the logical file(s) you want to check and dump the results in an outfile. You can then read, still in a CL program (or RPG), the outfile. The code for the DSPFD follows:
DSPFD FILE(aLibrary/aFile) TYPE(*MBR) OUTPUT(*OUTFILE) FILEATR(*LF) OUTFILE(QTEMP/XXX)
In this case, the file to read is QTEMP/XXX. Please note that if your logical file is multi-members, or if you used a generic name, you will have more than 1 record in the resulting file. Be sure to read them all. The field you want to check is MBINDX. Its text is "Access Path Valid: Y=Yes, N=No, H=Held". If the access path is invalid, ie if the return value is N, you may then want to check whether you can lock the object.
ALCOBJ OBJ((ALIBRARY/AFILE *FILE *EXCL)) WAIT(0)
If this is successful, the access path is invalid but nobody, including the system, is accessing the file. However, if there is a queue of logicals to be rebuilt, this file may be next. If you can't lock the file, it means that the system OR a user is in the process of regenerating the access path. If you were able to allocate the file, don't forget to deallocate it as follows.
DLCOBJ OBJ((ALIBRARY/AFILE *FILE *EXCL))
I hope this will be useful.
Have a question for an expert?
Please add a title for your question
Get answers from a TechTarget expert on whatever's puzzling you.