Reports / The report driver |
The OUTPUT TO REPORT instruction provides a data row to the report execution.
OUTPUT TO REPORT report-name ( parameters )
The OUTPUT TO REPORT instruction feeds the report routine with a single set of data values (called an input record), which corresponds usually to one printed line in the report output.
An input record is the ordered set of values returned by the expressions that you list between the parentheses following the report name in the OUTPUT TO REPORT statement. The specified values are passed to the report routine, as part of the input record. The input record typically corresponds to a retrieved row from the database.
SCHEMA stores TYPE t_cust RECORD LIKE customer.* ... DEFINE r_cust t_cust ... OUTPUT TO REPORT cust_report(r_cust.*) ... REPORT cust_report(r) DEFINE r t_cust ...
SCHEMA stores DEFINE o LIKE orders.* ... DECLARE order_c CURSOR FOR SELECT orders.* FROM orders ORDER BY ord_cust START REPORT order_list FOREACH order_c INTO o.* OUTPUT TO REPORT order_list(o.*) END FOREACH FINISH REPORT order_list ...
Special consideration should be taken regarding row ordering with reports: For example if the report groups rows with BEFORE GROUP OF or AFTER GROUP OF sections, the rows must be ordered by the column specified in these sections, and rows should preferably be ordered by the report driver to avoid two-pass reports.
If OUTPUT TO REPORT is not executed, none of the control blocks of the report routine are executed, even if the program also includes the START REPORT and FINISH REPORT statements.
The members of the input record that you specify in the expression list of the OUTPUT TO REPORT statement must correspond to elements of the formal argument list in the REPORT definition in their number and their position, and must be of compatible data types. At compile time, the number of parameters passed with the OUTPUT TO REPORT instruction is not checked against the DEFINE section of the report routine. This is a known behavior of the language.
Arguments of the TEXT and BYTE data types are passed by reference rather than by value; arguments of other data types are passed by value. A report can use the WORDWRAP operator with the PRINT statement to display TEXT values. A report cannot display BYTE values; the character string <byte value> in output from the report indicates a BYTE value.