PIVars and Page Counts for RAVE Report Subsets

Category

Rave - General

Question

How do I display a page count for a subset of pages within a RAVE report, for instance, the page count of a specific order in a report printing multiple customer orders?

Solution

RAVE provides an easy way to display the total page count of a report: the TotalPages report variable can be used to display expressions such as "Page N of M". However, you may find yourself needing to display a collective page count for, not the entire report, but for a part of it. For instance, if one were printing out a set of invoices, it might be desirable to have each invoice page display something along the lines of "Invoice Page N of M", where the page count M refers to the total number of pages in the current invoice, rather than the entire print job.

Such subset page counts can be obtained by using RAVE's Post Initialize Variable (PIVar) construct. PIVars are a little difficult to describe, but their use is fairly easy to grasp once you have seen them in action. In essence, a PIVar is a RAVE report parameter whose display value is determined after it is printed. To put this in more concrete terms, if you have a TRaveDataText control whose DataField property is set to a report parameter, within report the control will display the value of the report parameter at the time the control is printed. If you have a TRaveDataText control whose DataField property is set to a PIVar, within the report the control will display whatever value the PIVar obtains the next time this value is set after the control has been printed. This sounds absurd at first, but of course it's precisely the behavior which the TotalPages report variable displays - PIVars simply provide the report developer with a generalized, user-definable version of the same functionality.

Like report parameters, PIVars can be defined by adding a string list entry to a property ("PIVars") of a RAVE report project, report, or report page. (And like parameters, PIVar names are global in scope within the report project.) Note that if you are going to define and use PIVars within a report, you must set the AlwaysGenerate property of the report to True, as you must also do to obtain correct print behavior from TotalPages.

How do we use PIVars to obtain a subset report count? A typical standard page number display would use the following expression in a TRaveDataText DataField property:

'Page' & Report.CurrentPage & 'of' & Report.TotalPages

A subset page number display specification would instead look like

'Page' & Report.RelativePage & 'of' & PIVar.SubPageCount

(If you're not familiar with the RelativePage report variable, see the section of the acrobat on-line help file rppro4.pdf concerning the PageNumInit component.) In order to get this display to work, aside from resetting the RelativePage variable with an appropriately-placed TRavePageNumInit component, you must set the value of the PIVar "SubPageCount" as each subsection of your report is completed.

For a typical banded report, this can be accomplished by placing a TRaveCalcOp component in a body footer band of the report's master data view. Leave all the properties of the calc op component set at their default values with these exceptions: (1) Set the DestPIVar property to your equivalent of "SubPageCount", and (2) Set the Src1DataField property to

Report.RelativePage

Be sure that your TRaveCalcOp is earlier in the report's print order than the TRavePageNumInit component you will use to reset the RelativeReport variable!