CL code to work on a spoolfile

Tags:
Application development
AS/400
CLP
Hi, I wish to create a database file from a spoolfile. I know how to do this using cpysplf. I don't want the user to have to track down and enter the parameters for this command because, it will always be the same printfile and user. The only variable parameter will be the spoolfile number. So the code should pick up the first spoolfile in the (dedicated) output queue and automatically process the cpysplf command. Any ideas? Thanks

Answer Wiki

Thanks. We'll let you know when a new response is added.

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 <a href=”http://publib.boulder.ibm.com/infocenter/iseries/v5r4/index.jsp?topic=/apis/QUSLSPL.htm”>List Spooled Files (QUSLSPL) API</a> 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 <a href=”http://publib.boulder.ibm.com/infocenter/iseries/v5r4/index.jsp?topic=/apis/QUSRSPLA.htm”>Retrieve Spooled File Attributes (QUSRSPLA) API</a> to retrieve the spooled file number with format SPLA0100.

Tom

Discuss This Question:  

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following