The run report and run report with name statements are the two sanScript statements that run a report created with the Report Writer. Each statement has a number of optional clauses that allow additional report criteria to be specified at runtime. The report criteria that can be specified include restrictions, sorting criteria, legends and report destinations.
The restrictions added at runtime are applied to the report in addition to the report restrictions defined as part of the report definition. The restrictions must be based on any fields in the report’s main table, or any tables related to the main table.
Sorting criteria specified at runtime supersede the sorting criteria defined in the report definition. You can specify fields in the report to sort by, or you can choose to sort the report based on a key in the main table of the report.
The values for legend fields included in reports are also specified at runtime, using the legends clause. Most often, legends are used to display string values representing sorting and restriction options selected by the user.
The first value listed after the legends keyword will appear in the Legend field, the second value listed will appear in the Legend field, and so on.
If you include the destination clause, the report will be sent to the specified destination when the report is run. If you don’t specify a report destination when you use the run report or run report with name statement, the Report Destination window will be displayed automatically, allowing the user to specify a destination. This is useful when you want the user to be able to specify where the report is printed.
By default, the Printer check box will be marked and the Screen check box not marked when the Report Destination window is displayed. You can control the default values of these two check boxes when the Report Destination window is displayed. To do this, you must create two boolean global variables with the names Print to Screen and Print to Printer. If you set the global variable’s value to true, the corresponding check box in the Report Destination window will be marked. If you set the system variable to false, the check box won’t be marked. You must set the system variables before you execute the run report or run report with name statement.
You can use the printer clause to specify the printer to which the report will be printed. If you don’t include the printer clause or named printers are not supported on the current platform, the report will be sent to the currently-selected printer.