Retrieve list of Spooled files on System from SQL - IBM i
Spooled Files
Spooled files are generated when when system writes (prints) the data to an Output Queue. These could be Reports generated by the programs using Printer File (PRTF), System dumps or Job logs.
Traditional way of getting the list of spooled files is by using WRKSPLF command, which by default displays the list of spooled files for the current user.
Same can be retrieved from SQL with the use of table function SPOOLED_FILE_INFO. This is available in QSYS2.
Above query is simple and straight forward which returns the list of spooled files for the current user. Information returned is same as WRKSPLF (Work with Spooled files) and API (QGYOLSPL).
Let's have a look at how output of the query looks like.
This query returns a full list of columns (we will see all the columns towards the end) for the current user who is running the query.
We can make use of the parameters of the table function to retrieve spool files of all/other users and/or to narrow down the selection of the spool files.
In the above query,
- Parameter USER_NAME is used to select all the spool files for the specific user.
- Selecting few columns to look at the data we are interested in.
- SPOOLED_FILE_NAME - Name of the spooled file.
- STATUS - Status of the spool file. Below are the valid statuses.
- CLOSED
- DEFERRED
- DELETED
- HELD
- MESSAGE WAITING
- OPEN
- PENDING
- PRINTING
- READY
- SAVED
- SENDING
- WRITING
- CREATION_TIMESTAMP - Timestamp of the spooled file creation.
- JOB_NAME - Name of the job that created the spooled file.
- JOB_USER - Name of the user created the spooled file.
- JOB_NUMBER - number of the job that created the spooled file.
We could add additional parameters as required.
In the above query, we are using the parameters to retrieve the list of spooled files as per the selection. Below are the valid parameters for the table function. One thing to note here is filtering on multiple values for user name, output queue, user data or status makes the query to run slower.
- USER_NAME - Name of the user profile. This can contain up to 20 user names separated by blanks. Special values *ALL (all users on the system) or *CURUSR (Current user, default value) can be specified.
- STARTING_TIMESTAMP - Timestamp of the earliest spooled file to be returned. If not specified all the spooled files are returned (or less than ending_timestamp if specified).
- ENDING_TIMESTAMP - Timestamp of the latest spooled to be returned. If not specified all the spooled files are returned (or greater than starting_timestamp if specified).
- STATUS - Status of the spooled file. Full list of status values are specified above and '*' needs to be prefixed in order to retrieve the specific status (E.g.: To retrieve spooled files in CLOSED status *CLOSED needs to be specified). Special value of *ALL can be specified if all the statuses are to be considered, *ALL is the default value.
- JOB_NAME - Qualified job name. Special values '*' (Current job) and '*ALL' (All jobs matching with any other parameters specified, default) can be specified.
- OUTPUT_QUEUE - Name of the output queue to be specified followed by library name (library_name/output_queue_name). Up to 20 values can be specified separated by blanks. *ALL (default) can be used to consider all output queues.
- USER_DATA - Value of the user specified data. *ALL (default) can be specified to consider all.
- FORM_TYPE - Form type. *ALL (all form types, default) or *STD (Only files that specifies standard form type) can be specified.
- SYSTEM_NAME - Name of the system name in which spooled file is created on. Special values *CURRENT (Spooled files created on current system) or *ALL (All spooled files irrespective of system they were created on) can be specified.
In addition to the parameters of the table function, data can be further filtered by using the columns of the table function.
Full list of columns and more details on the parameters can e found here.
If you have any Suggestions or Feedback, Please leave a comment below or use Contact Form.
Comments
Post a Comment