BeforeDoPrint and AfterDoPrint Event Paragraphs

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
      .
Note: Included with AcuBench are several sample reports such as report1a that utilize these event paragraphs. See Sample Reports for details on locating and using AcuBench sample reports.

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:

  1. All of your report generation code can be generated from your .psf file, which means your manual code will not be lost in the regeneration process.
  2. You will only need to check in your .psf file into your version control system, as opposed to also having to check in the .cbl file.