The FINISH REPORT instruction finalizes a report execution.


FINISH REPORT report-name
  1. report-name is the name of the report to be ended.


FINISH REPORT closes the report driver. Therefore, it must be the last statement in the report driver and must follow a START REPORT statement that specifies the name of the same report.

FINISH REPORT must be the last statement in the report driver.

FINISH REPORT does the following:
  1. Completes the second pass, if report is a two-pass report. These 'second pass' activities handle the calculation and output of any aggregate values that are based on all the input records in the report, such as COUNT(*) or PERCENT(*) with no GROUP qualifier.
  2. Executes any AFTER GROUP OF control blocks.
  3. Executes any PAGE HEADER, ON LAST ROW, and PAGE TRAILER control blocks to complete the report.
  4. Copies data from the output buffers of the report to the destination.
  5. Closes the Select cursor on any temporary table that was created to order the input records or to perform aggregate calculations.

If the FINISH REPORT instruction fails, the runtime system will raise the error -8140, with the reason for the failure.