Using IBM i? Need to create Excel, CSV, HTML, JSON, PDF, SPOOL reports? Learn more about the fastest and least expensive tool for the job: SQL iQuery.
I'm working on a Print Monitor that will trap any SPOOL files created and do something with them. Right now I have it either copying the SPOOL file to another output queue or saving it for archival purposes.
I'm wondering if the QIBM_NOTIFY_CRTSPLF environment variable posts DTAQ entries before, during or after the SPOOL file is in RDY state? I can't really find the explicitly stated anywhere.
Also, does anyone else use one of these kinds of things? If so what do you do with it (use it for)?
Given the name of the environment variable, I'd take IBM literally from the manual:
"As spooled files are created, the entries are logged in the data queue."
If that's true, would mean you have to deal with data queue entries for open spool files and empty spool files. Maybe consider deferring the processing of the data queue entries until the job has completed.
Wrote a output queue handler to archive SNA-RJE emulation printer output 15 years ago. Created a data queue, configured the output queue to write dq entries when RDY, converted spool files to PDFs (some PSF/IPDS configuration magic from one the Printing RedBooks) and shipped 'em off to the IFS (or was it QDLS?). Burned the older PDFs to CDROM once a quarter. Much neater than the shelves of boxes of duplicate paper laying around, heck of lot more efficient to research older items, way cheaper than the optical systems being pushed at the time (fortunately didn't have to meet legal archival requirements- just providing a way to research items from the mainframe)
I now call the Retrieve SPLF Attributes API and test for the STATUS='*OPEN' and that's helpful. I sleep(5) and then lop around again. I may put in a counter t limit the number of retries. Next I'll have to see if I can check for status='*FIN" so I can "skip it". But I have a feeling I can't actually process that or retrieve the attributes, so I'll probably just get a message back.
Thanks Jack!
Haven't messed with the environment variable.
I've monitored queues with a program that periodically runs List Spooled Files (QUSLSPL) API on selected queues (list of queues comes from a table). Uses varied - cleanup, archive, ...
I see a DTAQ() keyword on CRTOUTQ, which might be simpler than the environment variable, but wouldn't work well if you want to handle every single queue. Sounds like it would be easier than what I had done in the past, though. Good thing is the *DTAQ messages are when spooled file is RDY, so no worry about checking status. Bad thing is if it goes from RDY to HLD to RDY again, you get another message for the same file. Program would have to update an attribute, maybe USRDTA, or something, so that it could avoid processing the same file twice. Or log them to a file (which would work if you're archiving). If you're moving or deleting, maybe this wouldn't matter.