Skip to main content

IBM i Services to Find Jobs Holding IFS File References

Dawn May shares how to use IBM i Services to display usage information for files.

In the blogs IBM i Access Client Solutions:  IFS PropertiesandDisplay File Usage InformationI reviewed how you could use Access Client Solutions or Navigator for i to display usage information for files in the IFS. Now you have another way with IBM i Services. This is a great addition as it gives you an SQL  interface to get at this information; it returns information similar to the Retrieve Object References (QP0LROR) API.

Using the QSYS.IFS_JOB_INFO()service, you can find the IFS object references for a given job. Using the QSYS2.IFS_OBJECT_LOCK_INFO(), you can find the job for a given object in the IFS.

As an example, I have a simple text file in my home directory that I had opened to edit via EDTF. When you know the job name, the IFS_JOB_INFO service will return information about object references for that job.

For example:

SELECT * FROM TABLE(QSYS2.IFS_JOB_INFO(JOB_NAME => '951043/DAWNM/QPADEV0056'));

This command returns many columns of information. The screen capture below shows the path name, the reference count, and the type of reference in use. 
 

Similarly, if you know the object you are interested in, you can use the IFS_OBJECT_LOCK_INFO service to find all jobs referencing that object.

SELECT * FROM TABLE (QSYS2.IFS_OBJECT_LOCK_INFO(PATH_NAME => '/home/DAWNM/TextDocument'));

Webinars

Stay on top of all things tech!
View upcoming & on-demand webinars →