DEFINE section in REPORT
Defines report parameters and local variables.
Syntax
DEFINE variable-name type-specification [,...]
- variable-name is an identifier.
- type-specification can be one of:
- A primitive type
- A record definition
- An array definition
- A dictionary definition
- A function type definition
- The name of a user defined type
- The name of a built-in class
- The name of an imported extension class
- The name of an imported 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 ROWto create a default report, you must pass all the values for each record of the report. - If an
ORDER BYsection is included, you must pass all the values thatORDER BYreferences for each input record of the report. - If you use the
AFTER GROUP OFcontrol 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 ROWcontrol 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
GROUPkeyword (anywhere outside theON LAST ROWcontrol 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.