IBMi (AS400) fans only : How to write to the same printerfile from more programs



#IBMiSample

A simple way is to leave the file open by ending programs with RETURN instead of SETON LR.



Example:


Program A calls Program B.
Program B opens a printerfile and write some pages in the spool file.
Program B closes with RETURN. The printer file is already open.




Program A calls Program B again.
Program B opens a printerfile (it is already open) and write some other pages on the same spool file.
Program B closes with RETURN. The printer file is already open.




Program A calls Program B again.
Program B opens a printerfile (it is already open) and write some other pages on the same spool file.
Program B closes with RETURN. The printer file is already open.

... and so on.




At the end, run RCLACTGRP ACTGRP(QILE). This command will end the QILE activation group, it means the spool file will also be closed.


I appreciate all the comments made on this blog.

Comments

Popular posts from this blog

(IBM i fans only) Efficient WRKSPLF with WSF - How to Search string into spooled files, Sort, and Generate PDFs on IBMi

(IBM i fans only) Detecting and Handling Non-Printable Characters in DB2 SQL Using LOCATE() and REPLACE() Functions

(IBM i fans only) How to Sniff User Access