I suspect that while the API appears to be running forever, it’s more the case that it’s just taking a whole lot more time due to processing all spool files on the system as opposed to just the spooled files for one user. This API doesn’t return until it actually has the entire list — which can take a while. This API is also limited to only returning information that will fit into the 16MB user space you have created. If there are more spool files than will fit in one space you are out of luck as there is no way to ask for the “next” 16MB.
Assuming you simply have a very large number of spool files on your system I would recommend using the Open List of Spooled Files API. This API has a few advantages that you might like:
- The API can return as soon as it has X spooled files to return. You specify X. While you’re working on the first X entries, the API (in a background job) continues to build more list entries. When you’re done with X, you ask for X more.
- The API is not limited to 16MB (assuming you are on a V5R3 or later release that is)
There are other advantages as well. Some of which are mentioned in the API documentation.
I hope this helps,