Modifying the contents of ReportWriter headers and footers

You can provide support for modification of a report’s header or footer each time the report is run. RW_HEADER_METHOD will be called for each line of the report and page header. RW_FOOTER_METHOD will be called for each line of the report and page footer.

We recommend that you use ReportWriter’s ability to place data fields in headers/footers instead of using these routines. These routines are maintained only for compatibility with previous versions.

RW_HEADER_METHOD

subroutine RW_HEADER_METHOD
    a_source            ,a      ;Source header line (a255)
    a_dest              ,a      ;Returned with destination header line (a255)
    a_width             ,d      ;Report width (d3)
    a_line              ,d      ;Line number(1-10) of header to be modified (d2)
    a_type              ,d      ;Indicates whether report header or page 
                                ; header is being modified (d1)
                                ; 0      Report header.
                                ; Non-0 Page header.
    a_control           ,a      ;ReportWriter control structure 

Discussion

ReportWriter will call RW_HEADER_METHOD for each line of the report header and page header, up to the last nonblank line. For example, if the header contains text on lines 1 and 2, this routine will be called twice. If the header contains text on lines 1 and 4, it will be called four times.

Because this routine is called when the report is being generated, the report width has already been determined. If you modify the header so that it is wider than the current report width, it may be truncated.

The version of this routine linked with ReportWriter in your original distribution is a “dummy” routine; it simply copies source to a_dest.

Examples

Here’s a sample RW_HEADER_METHOD subroutine that looks at an operating system environment variable and builds the first line of the page header based on that variable.

subroutine rw_header_method
;
; Description:  Modify the page header
;
; Arguments:  
;
    a_srchdr            ,a              ;Source header line
    a_dsthdr            ,a              ;Destination header line
    a_rptwid            ,d              ;Current report width
    a_line              ,d              ;Line number (1 thru 10)
    a_type              ,d              ;0=report header;non-0=page header
    a_ctl               ,a              ;Report control structure
record
    cmpnam      ,a25                    ;Company name to precede 
    len         ,d3
 
proc
    if (a_type) .and. 
      (a_line.eq.1) then                ;The first header line 
        begin
          xcall getlog("RPTCMPNAM", cmpnam, len) ;Get co. name first
            if (len) then
              xcall s_bld(a_dsthdr(1,a_rptwid),,"[%a] %a",cmpnam,a_srchdr)
            else                        ;If not set, get department name
              begin
                xcall getlog("RPTDEPNAM", cmpnam, len)
                if (len) then
                  xcall s_bld(a_dsthdr(1,a_rptwid),,"-%a- %a",cmpnam,a_srchdr)
                else
                  a_dsthdr = a_srchdr 
              end
        end
    else
      a_dsthdr = a_srchdr 
    xreturn
endsubroutine

RW_FOOTER_METHOD

subroutine RW_FOOTER_METHOD
    a_source    ,a      ;Source footer line (a255)
    a_dest      ,a      ;Returned with destination footer line (a255)
    a_width     ,d      ;Report width (d3)
    a_line      ,d      ;Line number (1-10) of footer to be modified (d2)
a_type          ,d      ;Indicates whether report footer or page footer 
                        ; is being modified (d1)
                        ; 0 = Report footer.
                        ; Non-0 = Page footer.

Discussion

ReportWriter will call this routine for each line of the report footer and page footer, up to the last nonblank line. (For example, if the footer contains text on lines 1 and 2, this routine will be called twice. If the footer contains text on lines 1 and 4, this routine will be called four times.)

Because this routine is called when the report is being generated, the report width has already been determined. If you modify the footer so that it is wider than the current report width, it may be truncated.

The version of this routine linked with ReportWriter in your original distribution is a “dummy” routine; it simply copies a_source to a_dest.