Introduction
Printing in IBM i isn't like sending documents to a printer from your desktop. Instead, IBM i uses a robust spool file and output queue system to manage and control printing processes. For beginners, this may seem a bit different—but once you understand the core concepts, it becomes very manageable.
In this blog, we’ll cover how printing works on IBM i, how to manage spool files, and how to control output queues and print jobs.
What is a Spool File?
A spool file is a temporary file that contains the output of a program intended for printing. It's created before the data is actually sent to the printer.
Think of a spool file like a print preview document in Windows—it holds your content until it’s ready to go to the printer.
Output Queues: Where Spool Files Wait
An output queue (OUTQ) is where spool files are stored until they are printed.
- Each spool file is directed to an output queue.
- You can have multiple output queues for different types of jobs or printers.
Common Output Queue Commands:
- WRKOUTQ OUTQ(QPRINT) – Work with output queue named QPRINT.
- WRKSPLF – Work with all spool files.
Viewing and Managing Spool Files
To view spool files:
WRKSPLF
- Use F5 to refresh.
- Use F11 to toggle views.
To view spool files for a specific user: WRKSPLF SELECT(USERNAME)
To view spool files in a specific output queue: WRKOUTQ OUTQ(MYLIB/MYOUTQ)
To display a specific spool file: DSPSPLF FILE(SPLFNAME)
Managing Spool Files
To hold (pause) a spool file: HLDSPLF FILE(SPLFNAME) JOB(123456/USER/XYZ) SPLNBR(1)
To release (resume) a spool file: RLSSPLF FILE(SPLFNAME) JOB(123456/USER/XYZ) SPLNBR(1)
To delete a spool file: DLTSPLF FILE(SPLFNAME) JOB(123456/USER/XYZ) SPLNBR(1)
To delete all spool files older than a certain date, IBM i doesn’t have a direct command like DLTOLDSPLF, but you can:
- Use WRKSPLF and sort by date manually.
- Or use a custom CL program to loop and delete based on date.
Printing Spool Files
Most spool files print automatically once placed in an output queue connected to a printer.
To manually send a spool file to print:
SNDTCPSPLF FILE(SPLFNAME) TOUSRID((USERID ADDRESS))
Or ensure the output queue is connected and not held:
CHGOUTQ OUTQ(MYLIB/MYOUTQ) STATUS(*START)
Redirecting Spool Files
To move a spool file to another output queue:
CHGSPLFA FILE(SPLFNAME) JOB(123456/USER/XYZ) SPLNBR(1) OUTQ(NEWLIB/NEWOUTQ)
Note: CHGSPLF does not exist; the correct command is CHGSPLFA (Change Spool File Attributes).
Automating Spool File Cleanup (Advanced)
To automate cleanup, you can write a CL program to delete spool files older than X days using SQL from QSYS2. Or set up job scheduler entries to call custom cleanup scripts.
Conclusion
Managing spool files and print jobs on IBM i becomes easy once you understand the terminology and commands:
· Spool Files are print-ready documents.
· Output Queues are holding areas for spool files.
· WRKSPLF / WRKOUTQ to view and manage print output.
· CHGSPLFA / DLTSPLF / RLSSPLF for managing files.
· Automate cleanup using scripts or scheduled jobs.
Understanding these basics allows users to handle printing needs smoothly and confidently.