Try OpenEdge Now
skip to main content
Programming Interfaces
Input/Output Processes : Creating Reports : Designing frames for reports : Programming example
 
Programming example
The exercise in this section demonstrates the techniques available when using headers and footers in a report.
To see an example of using headers and footers in a report:
1. Open i-10-10.p and run it.
2. Click Report. The Report Output dialog box appears:
Notice the header info at the top of each page. As you scroll through, you can see footers as well.
3. Click OK, then Exit, and then press SPACEBAR to return to the Procedure Editor.
The i-10-10.p code fragment shows the report generating code for this procedure.
i-10-10.p
     . . .
/*1*/  DEFINE FRAME f-body
         Name NO-LABEL
         Balance AT 40 FORMAT "$zzz,zz9.99 CR" SKIP
         Contact
         CreditLimit AT 40 FORMAT "$zzz,zz9.99 CR" SKIP
         Address NO-LABEL SKIP
         Holder NO-LABEL SKIP
         Phone SKIP(2)
         WITH SIDE-LABELS STREAM-IO.

/*2*/  OUTPUT TO "tut-temp.txt" PAGE-SIZE 25.
/*3*/  FOR EACH Customer
         WHERE Customer.Balance >= 1400 BREAK BY Customer.SalesRep:
/*4*/    DEFINE FRAME f-hdr
           HEADER
             "Date:" TODAY "Customer Report" AT 25
             SalesRep AT 55
             "Page" AT 65
             PAGE-NUMBER FORMAT ">>9" SKIP(1)
/*5*/      WITH PAGE-TOP FRAME f-hdr STREAM-IO.

/*6*/    DEFINE FRAME f-ftr
           HEADER
             "Customer Report"
             "continued next page"
/*7*/        WITH FRAME f-ftr PAGE-BOTTOM CENTERED STREAM-IO.

/*8*/    VIEW FRAME f-hdr.
         VIEW FRAME f-ftr.

         DISPLAY Name Balance Contact CreditLimit Address
/*9*/       (City + ", " + State + ", " + PostalCode) @ Holder Phone
            WITH FRAME f-body.

/*10*/   IF LAST-OF(SalesRep) THEN DO:
           HIDE FRAME f-ftr.
           PAGE.
         END.
       END. /* FOR EACH Customer */
OUTPUT CLOSE.
       . . .
The following notes summarize the techniques shown in this chapter:
*The body frame, which has no HEADER section, appears in its normal position, at the top of the file with other definitions.
*The PAGE-SIZE option sets the report page size.
*The use of the control break changes the report output from one report into a series of smaller reports-one for each sales rep.
*This HEADER frame comprises the running report head.
*PAGE-TOP places this frame at the top of the report page.
*This HEADER frame comprises the running page footer.
*PAGE-BOTTOM places the header frame at the bottom of the page.
*The VIEW statements force the AVM to evaluate the two HEADER frames on each iteration of the block.
*Here, the report creates an address string and uses the @ option to place the result at the Holder variable.
*The LAST-OF function is for checking for the end of a break group, allowing you to perform special tasks. In this case, the procedure suppresses the page footer because this break group report is complete. It also uses the PAGE statement to start a new page for the next break group report.