Hi Folks, i have been asked to print the Page number as page : N/X ( i.e the current page number is N out of total X pages). I knew that its possible to display the page number as page : N ( where N is the current page). But how can i pre determine the total pages of report in advance and have it printed in specified format? Please help me out
Software/Hardware used:
ASKED:
January 10, 2012 11:16 AM
UPDATED:
February 28, 2012 12:07 PM
There are plenty of discussions of the options in the case where you cannot calculate the number of lines. None of these solutions are trival,
Phil
If it is predictable as CharlieBrowne mentions, then you simply predict it by using whatever gives the correct result, e.g., number of input records. And if it’s not predictable, you’re into Phil’s “none are trivial” cases.
If I had to do it, I would print something like {Page nn of {xx}” on each page. The “nn” would be the actual page number, but the “{xx}” would be some identifiable constant that is guaranteed not to be anywhere else in the output except where the page count is intended to be.
I would generate the output and close the file. Then I would either retrieve the count of pages from the spooled file attributes or I’d grab the value from wherever I stored it in the program.
Finally, I would use the Get Spooled File Data (QSPGETSP) API to get the spooled output into one or more user spaces, and use the appropriate User Space APIs to change each occurrence of “{xx}” to the actual page count, and the Put Spooled File Data (QSPPUTSP) API to re-spool the output. The temporary original spooled copy could be deleted once the new copy is re-spooled.
Tom