Hi
If you want a CL only solution then you could look at using:
WRKOUTQ OUTQ(queue_name) OUTPUT(*PRINT)
to generate a list of the spool files on an output queue and then copy the generated report to a database file for processing using:
CPYSPLF FILE(QPRTSPLQ) TOFILE(filename) SPLNBR(*LAST)
Using CL you can then read through the file and parse out the relevant fields, e.g.:
2 - 11 Spool File Name
13 - 22 User ID
75 - 78 Spool File Number
84 - 93 Job Name
95 - 100 Job Number
Alternatively, you could add a data queue to the output queue so that when a spool file is written to the output queue an entry is also made to the data queue. You can then process the data queue as and when to retrieve the spool file and update your database.
Hope it helps
Jonathan
========================================================
Since command print formats are never guaranteed to remain constant, processing the result of OUTPUT(*PRINT) should always be avoided. Further, it’s almost always easier to do it the right way anyway.
The List Spooled Files (QUSLSPL) API will list the spooled files on an *OUTQ to a user space; use format SPLF0100. The first element in the list can be retrieved, and the identifiers from format SPLF0100 can be passed into the Retrieve Spooled File Attributes (QUSRSPLA) API to retrieve the spooled file number with format SPLA0100.
Tom
Discuss This Question: 2  Replies