Only the report itself contains BeforeDoPrint and AfterDoPrint events. You can provide paragraph names and code for these events using the steps described in Adding Report and Report Element Events. The code in these paragraphs perform READs and READ NEXTs, and initialize and reset print loops. They enable you to code instructions for what you want to do before and after each record is generated.
For example, you might define a BeforeDoPrint paragraph similar to this:
Myreport-BeforeDoPrint. move low-values to sales-key start sales key >= sales-key read sales-key next at end move 0 to Myreport-DOPRINTRTN-LOOP end-read .
And an AfterDoPrint paragraph that looked like this:
Myreport-AfterDoPrint. read sales-key next at end move 0 to Myreport-DOPRINTRTN-LOOP end-read .
To read data from a database with AcuSQL, the equivalent basic code might look like this:
PERFORM UNTIL sqlcode NOT = 0 EXEC SQL FETCH my-cursor INTO :C-RECORD END-EXEC IF sqlcode = 0 PERFORM Acu-RPT-report-DO-PRINT-RTN END-IF END-PERFORM.
These events were created so that all of your report generation code will be part of the .psf (project structure file). This is has two major advantages: