× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



This may be a can of worms you don't want to open.  If you do it on one
report, the flood of requests begins.  It is doable, but I'm not aware of
any easy methods.  You have a few choices to accomplish this.

1) If your page format is consistent, you know how many records you print
per page, and the number of records in the source for the report is stable
during the generation of the report you can use RTVMBRD or the Retrieve
Member Description (QUSRMBRD) API retrieve the number of records and
calculate the total pages.
2) Generate the report, copy it to a database file, update it with the total
number of pages, and copy it back to a spooled file.  Write a place holder
that won't appear in the data for the total number of pages (e.g., $%&#).
Create a file in QTEMP to hold the report.  Use a record length 1 greater
than the report width (e.g., 133 for a standard 132 wide report).  Use
CPYSPLF with CTLCHR(*FCFC) to copy the report to the temporary file.  This
will place the print control character in the first byte of the record so
you can preserve the page formatting when you copy the report back to a
spooled file.  Retrieve the total number of pages with either the Retrieve
Spooled File Attributes (QUSRSPLA) API or WRKOUTQ to a spooled file and
parse the spooled file.  Write and run a program to find and replace the
place holder with the total number of pages.  Pick an internally described
print file with a record length long enough for your report (e.g., qsysprt),
specify an OVRPRTF with CTLCHR(*FCFC), and use CPYF to copy your work file
directly to the print file.
3) You can have a variation of #2 using the spooled file APIs.
4) You can have a variation of #2 where your program that writes the total
number of pages generates the new report.

Keep in mind that your auditors may take exception to techniques 2 through 4
since you are manipulating the spooled file after it is generated.

Regards,
Stan McPartland

James David Rich wrote:

> I need to put 'page n of x' on a printout.  I know I can easily use a dds
> keyword to get the current page.  Is there something that tells my program
> how many pages there are?  Maybe a dds keyword like PAGE?
>
> James Rich
> james@dansfoods.com
>

+---
| This is the RPG/400 Mailing List!
| To submit a new message, send your mail to RPG400-L@midrange.com.
| To subscribe to this list send email to RPG400-L-SUB@midrange.com.
| To unsubscribe from this list send email to RPG400-L-UNSUB@midrange.com.
| Questions should be directed to the list owner/operator: david@midrange.com
+---

As an Amazon Associate we earn from qualifying purchases.

This thread ...


Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.