If you have a writer attached to your OUTQ you could just start the writer with :-
This should stop the writer as soon as there are no spooled files available.
AUTOEND() can be useful, but might need additional programming depending on how print jobs are scheduled overnight. Batch jobs might run between 10 PM and midnight. The writer might be started to print those jobs. By 12:30, those will have printed and the writer ends. Backup jobs run for an hour or so, and then more print jobs run — but the writer must now be restarted.
That is, the writer must be restarted every time a new spooled file hits the queue during the night whenever the writer previously ended.
If the status of the output queue only needs to be tested during a particular time span, the <a href=”http://publib.boulder.ibm.com/infocenter/iseries/v5r4/topic/apis/QUSLSPL.htm”>List Spooled Files (QUSLSPL) API</a> can be used to get a count of the number of spooled files on the queue. The API might be called in a loop after delays of 5, 10 or more minutes until zero files are found.