APIs by Example
When you need to locate the jobs currently holding locks against a specific object in the library file system QSYS.LIB, you can immediately do so using the Work with Object Locks (WRKOBJLCK) CL command. However, we presently have no similar command for objects in the IFS. Other options already exist, though. One is IBM Navigator for i, which includes a GUI that provides access to IFS objects and lock information. Another option is a virtually undocumented facility based on the Perform Miscellaneous File System Functions (QP0FPTOS) API that produces a printed list of IFS object lock holders. (For more information about these options, see the related references in “Find Out More” below.)
Sometimes, however, speed is of the essence, and running a CL command from a command line clearly outperforms the aforementioned alternatives. Because both options employ the Retrieve Object References (QP0LROR) API to retrieve object lock information, I made a shortcut to exploit this API to implement a Work with IFS Object Lock (WRKIFSLCK) CL command. Using the code I present in this article also gives you a starting point to create, for example, a Check IFS Object Lock (CHKIFSLCK) command to verify whether a specific IFS object is currently in use. You can use the code to write other similar useful CL commands to support a workflow or process involving the use of IFS objects as well.