Print a value from the previous page
Use Info Nodes and Reference Boxes to print a value that depends on the report layout. For example, you can print the total from the previous page.
When a report is generated from the report design document, the report is laid out as a paged stream (that is, the layout has been computed and the resulting document is split into pages). Some values on the report depend on where they occur in this paged stream. For example, you might want to print the "total from previous page" at the start of the next page. You cannot use a simple Word Box to capture this value, because it can vary depending on the page options for the report. For example, the page size and orientation will influence the total for each page.
To create a report layout that works with all page settings, use an Info Node to capture the layout-specific value and a Reference Box to print the value later in the report.
The Info Node is invisible and does not consume space in the layout. The Reference Box prints the (last) value set for an Info Node. In other words, you print the last stored value of an Info Node by placing a Reference Box on the report and specifying which Info Node to print. It will always print the immediately previous occurrence of the Info Node as located in the layout of the final document.
If there is no previous occurrence of the Info Node value in the paged stream prior to placing the Reference Box on the report page, the Default value for the Reference Box is printed.
This example illustrates how to print the total price (overalltotal
) from a
previous page.
In the Genero BDL report program
The REPORT
block of the Genero BDL file must calculate the desired
value and output it to the report. The following example is from the
OrderReport.4gl file in the demo sample programs:
ON EVERY ROW
LET lineitemprice = orderline.lineitem.unitprice * orderline.lineitem.quantity
LET overalltotal = overalltotal + lineitemprice
LET ordertotal = ordertotal + lineitemprice
PRINT orderline.*, lineitemprice, overalltotal, ordertotal
The variable overalltotal
contains the running total price of the
line items on the report.
In the report design document (.4rp)
Use these objects from the Toolbox in your report design:
- Info Node - Place this object in the container for the ON EVERY ROW trigger of your
Structure view. This creates an invisible column in your report line containing the value of the
Info Node.
The Value property of the Info Node must be a String.
You can use the fglValue member of the FGLNumericVariable class to convert overalltotal:
This formats the value of overalltotal as a String based on the default format set in the Genero DVM.overalltotal.fglValue
You can also use the format method of the Numeric class to convert to a string and also specify the format, as in this example:overalltotal.format("-,---,---,--&.&&")
- Two headers
at the top of the report structure:
- A First Page Header (Section = firstPageHeader) that will NOT include the Reference Box. If the Reference Box appeared on the first page, it would not find any Info Node value; the default value (if defined) would be printed instead.
- An Any Page Header (Section = anyPageHeader) that will include the Reference Box. This places the Reference Box at the top of all pages except the first.
- Reference Box
- Place this object in the Any Page Header and set these properties:
- For the InfoNode Name property, enter the name of the Info Node that you created.
- For the Text property, enter a string used to determine the maximum length of the value in the Info Node. This is necessary because the value will not be known at the time the Reference Box is positioned. For example, enter 000,000.00 as the maximum length for a value from a numeric data type, or MMMM as the maximum length for a value from a CHAR(4) data type.
- Word Box (Optional) - Use this object to add some text next to the Reference Box.
The Reference Box points to the immediately previous occurrence of the Info Node value in the paged stream. Because you placed the Reference Box in the Any Page Header, it will point to the last occurrence of the overalltotal value on the previous page.
Example
Figure 1 shows an example report structure (from the OrderReport.4rp report in the Reports demo). Figure 2 shows how this report looks when run.
Another example can be seen in the OrderList.4rp report of the Reports demo application.