Using the HEADER of a frame for running page heads
A frame can contain three distinct sections: body, HEADER, and BACKGROUND. Until now, everything you placed in a frame became part of the frame body. Using the keywords HEADER and BACKGROUND, you can also define two additional sections for your frames. The following code fragment shows how a DEFINE FRAME statement with these sections would look:
DEFINE FRAME f-example
body-item1 /* Can be field, variable, constant, image, or
body-item2 or rectangle. */
body-item3
HEADER
header-item1 /* Can be field, variable, constant, EXPRESSION,
header-item2 image, or rectangle. */
header-item3
BACKGROUND
background-item1 /* Can be field, variable, constant, EXPRESSION,
background-item2 image, or rectangle. */
background-item3
WITH SIDE-LABELS.
Frame backgrounds are typically used for placing a logo (image) or other graphic device in the background of a display frame. However, you cannot print graphics from ABL. For more information, see OpenEdge Development: ABL Reference. The rest of this section concentrates on the HEADER part of the frame.
The HEADER has a couple of special properties that allow you to implement running page heads and footers:
A HEADER section can contain expressions.
ABL re-evaluates expressions in a HEADER section each time the frame is redisplayed.
ABL suppresses field and variable labels in a header frame. If you want labels, you supply text strings in the frame definition.
If a HEADER frame contains an expression, field, or variable, the frame definition must take place in the context where ABL can provide new values. In other words, for an iterating report procedure, move the DEFINE FRAME statement from the top of your procedure into the FOR EACH block. Think of a HEADER frame as an executable statement. Just like a DISPLAY statement inside a FOR EACH block, the HEADER section of the DEFINE FRAME statement executes on every iteration of the FOR EACH block.
Also, note that a frame does not have to have a body—it can consist of a header only. You can modularize your report design with three frames: one each for page header, body, and page footer. This approach lets you adopt standard headers and footers.
Assume that All Around Sports wants a standard page header on every page of its reports. This is the information they want to include in the page header:
Date: mm/dd/yy Title sales-rep Page: xxx
The following code defines the first part of a procedure that implements the three-frame design.
/*1*/ OUTPUT TO "tut-temp.txt" PAGE-SIZE 25.
FOR EACH Customer WHERE Customer.Balance >= 1400
BREAK BY Customer.SalesRep WITH STREAM-IO:
DEFINE FRAME f-hdr
/*2*/ HEADER
/*3*/ "Date:" TODAY "Customer Report" AT 25
/*4*/ Customer.SalesRep AT 55
"Page" AT 65
/*5*/ PAGE-NUMBER FORMAT ">>9" SKIP(1)
/*6*/ WITH PAGE-TOP FRAME f-hdr STREAM-IO.
This part of the procedure contains the following language elements and points of interest:
The PAGE-SIZE option of the OUTPUT statement sets the default size for a report page.
The HEADER option tells the AVM to place the specified items in the header section at the top of the frame.
The TODAY function returns the current system date, and constitutes an expression.
The SalesRep initials come from the database and represent another part of the HEADER that the AVM must evaluate.
The PAGE-NUMBER function tracks the current page number (expression).
The PAGE-TOP FRAME f-hdr further defines what kind of HEADER the frame is. PAGE-TOP specifies where to place the frame and makes the frame a running page head.