Use a Subreport to Include Unrelated Data in the Same Report

This example demonstrates how you might use a subreport (a separate report within a main or ‘primary’ report) in order to include indirectly related or unrelated data in the same report.

This particular example uses a subreport to enable the value of a ClearSCADA Parameter to be included in a report, however you can use subreports whenever you want to include more than one query in a report. You can, for example, use subreports if you want to include data from any database tables that are unrelated to another, and for which the records in those tables cannot therefore be linked together. You might also want to consider using subreports to display more than one view of the same data in a single primary report.

For detailed information on subreports, see the documentation supplied with the Crystal Reports application.

As an alternative to using subreports, you might want to consider using ClearSCADA Data Grids (see Custom Tables and Fields). Data Grids enable you to collate data from a variety of different sources in a single table, which you can then include in a report.

Example:

A particular ClearSCADA system is split into geographical zones. ClearSCADA Grid Reference Parameters are used to store the map grid references that define each zone’s geographical location. The grid references are included in any Mimics and reports that relate to specific zones.

Each ClearSCADA Grid Reference Parameter stores data that specifies the geographical location in which an area of plant is located. However, that map reference data is not directly related to the database records that store the actual plant data—there is no direct link between the database table that stores the grid reference data, and the database tables that store the plant data for a particular zone. Therefore, in order to include the ClearSCADA Grid Reference Parameter data in a report, that data is included in a Crystal Reports subreport.

A primary report is produced, which references the database table(s) that contain the plant data. The data that is included in the report is constrained to that of the relevant zone. (For instance, by using the Select Expert window to restrict the data to that of the relevant ParentGroupName.)

The map grid reference that defines the zone’s geographical location is to be displayed in the primary report’s Report Header.

A subreport is added to the primary report, in order to include the grid reference data. (To add a subreport to a primary report, select the Insert Subreport button in the Crystal Reports application, or select the Insert menu, followed by the Subreport option.)

The subreport is given a suitable name—‘Map Reference’.

As with the primary report, the relevant ODBC connection is specified to enable the Crystal Reports application to access the ClearSCADA database and include data in the subreport. However, unlike the primary report, which references other database table(s), the subreport is configured to reference the CParamGridRef table—the database table that stores ClearSCADA Grid Reference Parameter data. The table has three configuration fields, Ref1, Ref2, and Ref3, which are used to store the map grid data. The three fields are included in the subreport.

The subreport is embedded in the primary report’s header. Additionally, in this particular report, static text is also added to the report header, along with one of the database fields from the primary report:

As with any subreport, the subreport’s tab (named, in this case, ‘Map Reference’, after the subreport to which it relates) is used to configure the subreport’s ‘definition’ (the layout and information that is to be included in that subreport). In this particular example, for instance, the Select Expert window is used to restrict the grid reference data to that of the relevant map grid reference:

This results in a report with the following layout:

Further Infosrmation

ClearSCADA Parameters, including Grid Reference Parameters: see Using Parameters to Store Static Data Values in the ClearSCADA Guide to Core Configuration.

Specify an ODBC Connection: see Accessing the ClearSCADA Database.

For an example that further demonstrates use of the Select Expert window, see Limit the Data that is Included in a Report.


Disclaimer

ClearSCADA 2017 R3