Did you know that you can display file usage information for files stored in the Integrated File System? And that this usage information includes the details about jobs that are using a file? Or that you can display file system objects for a job? This has been part of the operating system for many releases (it was introduced in 5.2!), but I think it is a very little-known and seldom-used capability.
I'll use a simple example to demonstrate...
I have a stream file in the root directory named DAWNMAY and I have opened this file in edit mode in a telnet session.
Using IBM Systems Director Navigator (this capability also exists in System i Navigator), begin by opening File Systems and then opening up the Integrated File System. Navigate to the file of interest – in my case I just had to open up the Root directory to find the file. Take the Properties option.
Open the Use tab where you will find a section on Current usage. Clicking on the Show usage button will allow you to access more detailed information.
Now you can see that there is one job using that file.
Select the option that makes the Details.... button available.
And now you get the details of the job with that particular file in use:
There is a second way to approach this – and that's by starting with the job that is using the file. For example, you can open Work Management and navigate to the job of interest in whatever manner you choose (Active Jobs, Server Jobs, or whatever navigation you like). Once you have found the job you are interested in, right click on it to get to the options – take Details, Open Files, and then File System Objects.
The results list the file system objects that are in use by that job.
There are two underlying APIs that can be used to collect similar information programmatically: