DEFINE section in REPORT
Defines report parameters and local variables.
Syntax
DEFINE variable-name data-type [,...]
- variable-name is an identifier.
- data-type can be a primitive data type, a user defined type, a built-in class, an imported package class, or a Java class.
Usage
The DEFINE
section declares a data type for each formal argument in the
REPORT
prototype and for any additional local variables that can be referenced only
within the REPORT
program block.
The scope of report variables is the REPORT
routine. However, report variables
are not allocated on the FGL stack like regular FUNCTION
variables: The lifetime of
report variables is the duration of the program, like module or global variables. As result, they
persist across OUTPUT TO REPORT
and FINISH REPORT
calls. When
restarting a report, consider initializing the local report variables in FIRST PAGE HEADER
.
DEFINE
section, if any of the following conditions is true:- If you specify
FORMAT EVERY ROW
to create a default report, you must pass all the values for each record of the report. - If an
ORDER BY
section is included, you must pass all the values thatORDER BY
references for each input record of the report. - If you use the
AFTER GROUP OF
control block, you must pass at least the arguments that are named in that control block. - If an aggregate that depends on all records of the report appears anywhere except in the
ON LAST ROW
control block, you must pass each of the records of the report through the argument list.
GROUP PERCENT(*)
(anywhere in a report).- Any aggregate without the
GROUP
keyword (anywhere outside theON LAST ROW
control block).
When a report calls an aggregate function, an error might result if any argument of an aggregate function is not also a format argument of the report. You can, however, use global or module variables as arguments of aggregates, if the value of the variable does not change while the report is executing.