This procedure prints the date in the first line at the top of each page of a report. Instead of using TODAY in the FORM statement, the procedure uses a variable to hold the date. This ensures that the same date appears on all pages of the report, even if this procedure runs through midnight.
r-today.p
DEFINE VARIABLE rptdate AS DATE NO-UNDO.
OUTPUT TO PRINTER.
rptdate = TODAY. FORM HEADER rptdate "Customer List" AT 34
"Page" AT 66 PAGE-NUMBER FORMAT ">>>9" SKIP(2)
WITH NO-BOX PAGE-TOP.
VIEW.
FOR EACH Customer NO-LOCK:
DISPLAY Customer.Name AT 1 Customer.Address AT 31
Customer.City + ", " + " " + Customer.State FORMAT "x(35)" AT 31
WITH NO-BOX NO-LABELS CENTERED.
END.
PAGE-TOP frames are re-evaluated on every new page. Therefore, if you do not use a variable for the date, a different date is displayed on the following page(s) if the report starts before midnight and ends after midnight.