DECLARE-PROCEDURE

Function

Declares procedures triggered when a specified event occurs.

Syntax

DECLARE-PROCEDURE
[FOR-REPORTS=(report_name1[,report_namei]...)]
[BEFORE-REPORT=procedure_name[(arg1[,argi]...)]]
[AFTER-REPORT=procedure_name[(arg1[,argi]...)]]
[BEFORE-PAGE=procedure_name[(arg1[,argi]...)]]
[AFTER-PAGE=procedure_name[(arg1[,argi]...)]]
END-DECLARE

Arguments

FOR-REPORTS

Reports that use the given procedures. Required only for programs with multiple reports.

BEFORE-REPORT

Procedure executed at the time of the execution of the first command which causes output to be generated (PRINT). It can be used, for example, to create a report heading.

AFTER-REPORT

Procedure executed just before the report file is closed at the end of the report. It can be used to print totals or other closing summary information. If no report was generated, the procedure does not execute.

BEFORE-PAGE

Procedure executed at the beginning of every page, just before the first output command for the page. It can be used, for example, to set up page totals.

AFTER-PAGE

Procedure executed just before each page is written to the file. It can be used, for example, to display page totals.

You can optionally specify arguments to pass to any of the procedures. Arguments can be any variable, column, or literal.

Description

DECLARE-PROCEDURE can be used to define Production Reporting procedures to invoke before or after a report is printed or before the beginning or end of each page.

Issue DECLARE-PROCEDURE in the SETUP section. For multiple reports, you can use the command as often as required to declare procedures required by all the reports. If you issue multiple DECLARE-PROCEDURE commands, the last one takes precedence. In this way, you can use one command to declare common procedures for ALL reports and others to declare unique procedures for individual reports. The referenced procedures can accept arguments.

If no FOR-REPORTS is specified, ALL is assumed. Initially, the default for each of the four procedure types is NONE. If a procedure is defined in one DECLARE‑PROCEDURE for a report, that procedure is used unless NONE is specified.

Use the USE-PROCEDURE command to change the procedures to use at run-time. To turn a procedure off, specify NONE in the USE-PROCEDURE statement.

Examples

declare-procedure              ! These procedures will
  before-report=report_heading ! be used by all reports
  after-report=report_footing
end-declare
declare-procedure              ! These procedures will
  for-reports=(customer)       ! be used by the customer
  before-page=page_setup       ! report
  after-page=page_totals
end-declare

See Also

USE-PROCEDURE