Page number is simple - check the rlu help
Total number harder - requires RPG code that computes number of pages before the first header is printed. Here is discussion.
http://itknowledgeexchange.techtarget.com/itanswers/how-to-display-page-1-of-n/
Phil
Last Wiki Answer Submitted: December 21, 2009 10:56 am by philpl1jb44,220 pts.
All Answer Wiki Contributors: philpl1jb44,220 pts.
If you live outside the United States, by submitting your email address you consent to having your personal data transferred to and processed in the United States.
As noted, page number is simply a field that you print with the page number in it. An externally-described printerfile written by RPG can have automated page number handling. The RLU manual says that the PAGENBR attribute can be used to specify the printed location.
However, that only covers the current page number. The total number of pages isn’t known until all of the pages are printed. You will either have to calculate somehow the number of pages before you start printing or process the spooled file after you are finished to update every page with the total.
You could use CPYSPLF to a PF and update records that have page numbers. Then CPYF TOFILE(*PRINT) to generate a new spooled file with your updated page numbers. Or you can use the Spooled File APIs to copy the spooled file into user spaces, update the page number in the spaces, and generate a new spooled file from the updated spaces.
Usually, some kind of constant would be placed in the original spooled file to mark where the updates should be done. E.g., you might print “*PN<” to mark the location where a “PageNumber” can be inserted. That gives you something to search for when you process the PF or the spaces. You might create a utility program that you can for any spooled file that you want this done to.
In any case, RLU is only a “Report Layout Utility”. It doesn’t actually do any printerfile processing. The processing is done by your programming.
As noted, page number is simply a field that you print with the page number in it. An externally-described printerfile written by RPG can have automated page number handling. The RLU manual says that the PAGENBR attribute can be used to specify the printed location.
However, that only covers the current page number. The total number of pages isn’t known until all of the pages are printed. You will either have to calculate somehow the number of pages before you start printing or process the spooled file after you are finished to update every page with the total.
You could use CPYSPLF to a PF and update records that have page numbers. Then CPYF TOFILE(*PRINT) to generate a new spooled file with your updated page numbers. Or you can use the Spooled File APIs to copy the spooled file into user spaces, update the page number in the spaces, and generate a new spooled file from the updated spaces.
Usually, some kind of constant would be placed in the original spooled file to mark where the updates should be done. E.g., you might print “*PN<” to mark the location where a “PageNumber” can be inserted. That gives you something to search for when you process the PF or the spaces. You might create a utility program that you can for any spooled file that you want this done to.
In any case, RLU is only a “Report Layout Utility”. It doesn’t actually do any printerfile processing. The processing is done by your programming.
Tom