The START REPORT instruction initializes a report execution.
START REPORT report-routine [ TO to-clause ] [ WITH dimension-option [,...]]
{ SCREEN | PRINTER | [FILE] filename | PIPE program [ IN FORM MODE | IN LINE MODE ] | XML HANDLER sax-handler-object | OUTPUT destination-expr [ DESTINATION { program | filename} ] }
{ LEFT MARGIN = m-left | RIGHT MARGIN = m-right | TOP MARGIN = m-top | BOTTOM MARGIN = m-bottom | PAGE LENGTH = m-length | TOP OF PAGE = c-top }
The START REPORT statement initializes a report. The instruction allows you to specify the report output destination and the page dimensions and margins.
START REPORT typically precedes a loop instruction such as FOR, FOREACH, or WHILE in which OUTPUT TO REPORT feeds the report routine with data. After the loop terminates, FINISH REPORT completes the processing of the output.
DEFINE file_name VARCHAR(200), page_size INTEGER ... START REPORT myrep TO FILE file_name WITH PAGE LENGTH = page_size
If a START REPORT statement references a report that is already running, the report is re-initialized; any output might be unpredictable.
The TO clause can be used to specify a destination for output. If you omit the TO clause, the Genero runtime system sends report output to the destination specified in the report routine definition. If the report routine does not define an OUTPUT clause, the report output is sent by default to the report viewer when in GUI mode, or to the screen when in TUI mode.
Report output can be specified dynamically as follows:
The SCREEN option specifies that output is to the report window. The way the report is displayed to the end user depends on whether you are in TUI mode or GUI mode. In TUI mode, the report output displays to the terminal screen. In GUI mode, the report output displays in a dedicated popup window called the Report Viewer.
The PRINTER option instructs the runtime system to output the report to the device or program defined by the DBPRINT environment variable.
When using the FILE option, you can specify a file name as the report destination. Output will be sent to the specified file. If the file exists, its content will be overwritten by the new report output. The FILE keyword is optional, but it's best to include it to make your code more readable.
The PIPE option defines a program, shell script, or command line to which the report output must be sent, using the standard input channel. When using the TUI mode, you can use the IN [LINE|FORM] MODE option to specify whether the program is in line mode or in formatted mode when report output is sent to a pipe.
The TO OUTPUT option allows you to specify one of the output options dynamically at runtime. The character string expression must be one of: "SCREEN", "PRINTER", "FILE", "PIPE", "PIPE IN LINE MODE", " PIPE IN FORM MODE". If the expression specifies "FILE" or "PIPE", you can also specify a filename or program in a character variable following the DESTINATION keyword.
The XML HANDLER option indicates that the report output will be generated as XML and redirected to a SAX-document handler. When using XML output, the report result can be shown in the Genero Report Engine installed on the front-end workstation. See XML output for more details.
The WITH clause defines the dimensions of each report page and the left, top, right and bottom margins. The values corresponding to a margin and page length must be valid integer expressions. The margins can be defined in any order, but a comma "," is required to separate two page dimensions options.
In addition to the page dimension options, the TOP OF PAGE clause can specify a page-eject sequence for a printer. On some systems, specifying this value can reduce the time required for a large report to produce output, because SKIP TO TOP OF PAGE can substitute this value for multiple line feeds.