Crystal Reports XI-2 Day Training Course v1-4

Download as pdf or txt
Download as pdf or txt
You are on page 1of 110

Crystal Reports XI Training Notes

Issue: 1.4 Issued Date: Jan 07

Crystal Reports XI Training Course

Issue Details
Issue 1.0 1.1 1.2 1.3 1.4 Date 20/10/06 25/10/06 08/11/06 23/11/06 03/01/07 Author D. Mountford D. Mountford D. Mountford N. Anstee D. Mountford Comments Initial draft complete. Minor modifications. Minor modifications. Minor modifications. Minor modifications.

Table of Contents

Issue 1.4

Crystal Reports XI Training Course

ii

Issue 1.4

Table of Contents

Crystal Reports XI Training Course

Table of Contents
Introduction ............................................................................................. 1-1 1.1 Crystal Reports................................................................................ 1-1 1.2 ClearSCADA.................................................................................... 1-1 2 Installation & Configuration..................................................................... 2-1 3 Connecting to a Data Source ................................................................. 3-1 3.1 Setup a System DSN ...................................................................... 3-1 3.2 Connecting Crystal Reports to ClearSCADA .................................. 3-2 3.3 Selecting Database Information ...................................................... 3-4 3.4 Displaying Database Information .................................................... 3-7 4 Record Selection .................................................................................... 4-1 4.1 Crystal Reports in ClearSCADA...................................................... 4-1 4.2 Maintenance Report (Version 1) ..................................................... 4-5 4.3 Select Expert ................................................................................... 4-7 4.4 Record Sort Expert........................................................................ 4-11 4.5 Report Generation & Displaying.................................................... 4-12 5 Report Formatting................................................................................... 5-1 5.1 Maintenance Report (Version 2) ..................................................... 5-1 5.2 Inserting Picture Objects ................................................................. 5-2 5.3 Inserting Special Fields ................................................................... 5-2 5.4 Inserting a Page Footer................................................................... 5-3 5.5 Highlighting...................................................................................... 5-4 6 Group Selection ...................................................................................... 6-1 6.1 Predictive Maintenance Report (Version 1) .................................... 6-1 6.2 Group Expert ................................................................................... 6-3 7 Summary Fields...................................................................................... 7-1 7.1 Predictive Maintenance Report (Version 2) .................................... 7-1 7.2 Inserting a Summary ....................................................................... 7-3 7.3 Drill Down ........................................................................................ 7-4 7.4 Inserting a Box ................................................................................ 7-6 7.5 Inserting a Line................................................................................ 7-7 8 Charts ..................................................................................................... 8-1 8.1 Predictive Maintenance Report (Version 3) .................................... 8-1 8.2 Insert Chart...................................................................................... 8-1 9 Day 1 Review.......................................................................................... 9-1 9.1 Day 1 Review Report ...................................................................... 9-1 10 Parameterized Reports ..................................................................... 10-1 10.1 Production Report (Version 1)....................................................... 10-1 10.2 Inserting Parameter Fields ............................................................ 10-2 10.3 Parameters from ClearSCADA ..................................................... 10-7 11 Report Sections................................................................................. 11-1 11.1 Production Report (Version 2)....................................................... 11-1 11.2 Section Expert ............................................................................... 11-2 12 Report Templates ............................................................................. 12-1 12.1 Production Report (Version 3)....................................................... 12-1 12.2 Template Expert ............................................................................ 12-1 12.3 Creating a Report Template.......................................................... 12-3 12.4 Inserting a Template Field Object ................................................. 12-4 13 Creating Formulas ............................................................................ 13-1 1

Table of Contents

Issue 1.4

iii

Crystal Reports XI Training Course

13.1 Device Status Summary Report.................................................... 13-1 13.2 Inserting Formula Fields................................................................ 13-3 14 Subreports......................................................................................... 14-1 14.1 Master Report................................................................................ 14-1 14.2 Inserting Subreports ...................................................................... 14-2 15 Comments......................................................................................... 15-1 16 Troubleshooting ................................................................................ 16-1 16.1 Failed to generate a Crystal Report .............................................. 16-1 17 Definitions/Abbreviations .................................................................. 17-1

iv

Issue 1.4

Table of Contents

Crystal Reports XI Training Course

1 Introduction
The purpose of this course is to introduce users to the Crystal Reports XI software and its use in conjunction with ClearSCADA (SCADA Management Software). The course will cover the installation and configuration of both Crystal Reports and ClearSCADA, an overview of the interface between Crystal Reports and ClearSCADA, and the creation of custom Crystal Reports using ClearSCADA as its data source. As part of this course many of the tools and features of Crystal Reports will be explored through the creation of real-world example reports. These reports will range from the usage of simple features such as record selection and basic report formatting, to advanced features such as formulas and sub-reports. Although the primary focus of this course is Crystal Reports, some knowledge of ClearSCADA will be required to successfully achieve the outcomes of the course. For this reason some time will be spent introducing users to both Crystal Reports and ClearSCADA concepts. 1.1 Crystal Reports

Crystal Reports is a Business Intelligence application used to design and generate content-rich, professional reports suited to individual or business needs. This allows report users to quickly analyze and interpret the information that is important to them (or their business). Crystal includes an extensive set of interfaces to a myriad of data sources. Simple reports can be generated quickly and easily with an intuitive report generation wizard, and Crystal also includes a comprehensive toolset for producing complex or specialised reports. 1.2 ClearSCADA

ClearSCADA is a true client-server architecture SCADA Management Software package. The software is made up of three (3) major components: Database Server The Database Server is responsible for storing and maintaining the information contained within the ClearSCADA Database and serving that information to clients, which have made a request on that data. The Database server is also responsible for providing the core functionality of the SCADA system, i.e. the ability to request and receive data from real world devices and then use that information in a meaningful way.

Section 1 - Introduction

Issue 1.4

1-1

Crystal Reports XI Training Course

Communications Drivers The Communications Drivers are responsible for defining and controlling communications between the ClearSCADA server and many types of real world devices. ClearSCADA supports both simple drivers, such as Modbus and OPC, and more advanced drivers, such as DNP3. ViewX/WebX Clients ClearSCADA provides two (2) client-side interfaces for communication between a ClearSCADA server and a client, namely ViewX and WebX. These clients run on computers that access the ClearSCADA database (stored on the ClearSCADA server) via a network connection. ViewX is the primary client application and is used to configure and view all aspects of the system. We will be using ViewX throughout this course for the creation of Crystal Report objects, and the creation and configuration of other objects to be used as part of our reports. The following is a high-level overview of how the ClearSCADA Server interfaces with both real-world devices and clients:

1-2

Issue 1.4

Section 1 - Introduction

Crystal Reports XI Training Course

2 Installation & Configuration


The installation and configuration of ClearSCADA and Crystal Reports has already been done for you.

Section 2 - Installation & Configuration

Issue 1.4

2-1

Crystal Reports XI Training Course

2-2

Issue 1.4

Section 2 - Installation & Configuration

Crystal Reports XI Training Course

3 Connecting to a Data Source


One of the key features of Crystal Reports is that it provides connectivity to a wide variety of data sources. This includes local database files such as a Microsoft Access database, or pre-existing ODBC data sources (for example). As part of this course we will be using Crystal Reports to connect to the ClearSCADA database as an ODBC data source, through the use of a System DSN (Data Source Name). Refer to the following section for details on how to create and configure a System DSN for ClearSCADA. 3.1 Setup a System DSN

To connect Crystal Reports to the ClearSCADA database a DSN must be created. This provides connectivity to the database through the ODBC interface. The DSN contains the database name, directory, database driver, User ID, password, and other information. Once setup this DSN can be used to retrieve information from the ClearSCADA database by third party applications, such as Crystal Reports. To setup a System DSN: Open the Windows Control Panel. Open the Administrative Tools. Open Data Sources (ODBC). Select the System DSN tab. A System DSN is available to all applications or users on the local machine. NOTE: If there is already an entry named ClearSCADA in this list, click on it, select Configure and ensure the settings are as per the following steps. Select the Add button. Select the Control Microsystems ClearSCADA Driver option from the list and click finish. On the form displayed enter the following details: o Name: Enter ClearSCADA. o System: Select MAIN from the drop-down menu. o Local Time: Tick the box. o User Name: Enter Eng o Password: Leave blank o Leave all other settings as defaults.

The settings should look similar to the screenshot below:

Section 3 - Connecting to a Data Source

Issue 1.4

3-1

Crystal Reports XI Training Course

Click the Ok button. Click the Ok button to finish creating the DSN.

Crystal Reports will now be able to connect to and retrieve information from the ClearSCADA database for use in reports. NOTE: Entering a user name and/or password in the DSN configuration is not always recommended, as this means that anyone who can access the DSN can access the ClearSCADA database without logging in.

3.2

Connecting Crystal Reports to ClearSCADA

We are now ready to create a connection between Crystal Reports and the ClearSCADA database, using the System DSN created above. Click on the Start button and select All Programs > BusinessObjects 11 > Crystal Reports > Crystal Reports 11. If the Business Object Registration Wizard opens, click the Register Later button. Cancel and/or close any dialogs that popup asking to check for Crystal Reports XI Updates. Click File > New > Blank Report (or click on the Blank Report link under the New Reports heading on the Start Page). You should be presented with a screen that looks similar to below:

3-2

Issue 1.4

Section 3 - Connecting to a Data Source

Crystal Reports XI Training Course

In the Available Data Sources frame click the plus icon next to the Create New Connection entry to expand it. From the options presented click the plus icon next to the ODBC (RDO) folder to expand it. This will open a new window for selecting the desired Data Source and should look similar to below:

Section 3 - Connecting to a Data Source

Issue 1.4

3-3

Crystal Reports XI Training Course

In the Data Source Name list select the ClearSCADA option. Click the Next button. In the User ID field enter Eng and click Finish.

You should now see a ClearSCADA entry under the ODBC (RDO) folder. Under this entry is an alphabetical list of all of the tables configured in the ClearSCADA database. This list also includes any configured Data Grids and Historic Views, which will be covered in more depth later. 3.3 Selecting Database Information

We will now select a table to add to the report and display some information. Scroll down until you find the table named CDBPoint. Click on the CDBPoint entry then click on the right arrow (or double click on the CDBPoint entry) to add the table to the Selected Tables list.

You should have a screen similar to below:

3-4

Issue 1.4

Section 3 - Connecting to a Data Source

Crystal Reports XI Training Course

Click Ok to close the Database Expert.

One other thing we will do before we select the information we wish to display on our report, is to enable the Grid option feature for all of our reports. This allows us to easily line up and resize fields making reports appear neater. Select File > Options. In the Layout tab under Design View, check the tick-box next to the word Grid. Click Ok to close the Options.

NOTE: The default grid size can be modified if required using the Grid options > Grid Size. Now that our Crystal Report is linked to a table in our ClearSCADA database, we are ready to select the information within this table that we wish to display. Firstly, lets make sure we have the toolbars and explorer bars we will be using on display. Throughout this course we will use icons from each of the toolbars, so please ensure that all of the toolbars are displayed by clicking View > Toolbars. Make sure each toolbar has a tick next to it.

Section 3 - Connecting to a Data Source

Issue 1.4

3-5

Crystal Reports XI Training Course

The explorer bar of interest to us is the Field Explorer bar. Close any other open explorer bars for now and ensure that the Field Explorer is shown by clicking View > Field Explorer.

We are now ready to browse the database information associated with the data source the report is linked to. Within the Field Explorer click the plus icon next to the Database Fields entry to expand it. Under this you should see a CDBPoint entry. Click the plus icon next to the CDBPoint entry to expand it. Under this you should see an alphabetical list of entries. These are all of the Configuration Fields, Data Fields and Aggregates associated with the ClearSCADA table selected.

If you cannot see the full names of the entries here, expand the width of the Field Explorer bar until you can. You should have a screen that looks similar to below:

We can now insert the desired information into the report. The fields we are interested in for this example are FullName and CurrentValueFormatted. The FullName property is a unique reference to an object that is comprised of the objects name and full path within the database structure. The CurrentValueFormatted property is common to all point objects within the

3-6

Issue 1.4

Section 3 - Connecting to a Data Source

Crystal Reports XI Training Course

database and contains the current value of the point, with any formatting or units included. As an example say we have a point in our database that measures a dam level. If its FullName is Sites.Eastern WTP.Dam Level, this tells us that the points name is Dam Level and shows us its location of the point within the database structure. If its CurrentValueFormatted is 6805.503 M/L, this tells us the points current value, units and formatting, but the raw value returned from the field might be 6805.5032349951. Within the Field Explorer find the entry named FullName under CDBPoint. Click and hold the mouse button on it and drag it onto the report workspace. Drop it (release the mouse button) in between the lines in the Details section. Position the FullName field to the far left of the Details section by dragging and dropping it. Increase the width of the field to around 2/3 the width of the page by clicking on the field and using the resize handle on the right-hand side. Find the entry named CurrentValueFormatted under CDBPoint. Click and hold the mouse button on it and drag it onto the report workspace. Drop it (release the mouse button) in between the lines in the Details section. Position the CurrentValueFormatted field to the right of the FullName field by dragging and dropping it.

When fields are dragged into the Details section of a report, a heading is also created in the Page Header section. Fields in the Page Header section of a report are printed on every new page within the report. This heading will default to the field name associated with it. The headings can be made more readable by modifying the name of the heading. To do this right-click on the field and select Edit Text (or double click on it) and change the text as desired. You may have noticed that once a field is dragged onto a report a green tick appears next to its name in the Field Explorer. This simply means that the field is being displayed somewhere on the report. This applies to all of the field types, including formulas and parameters, which will be covered later. NOTE: This green tick also appears if the database field is used within the record Select Expert and is not actually displayed anywhere on the report. This will be covered in more depth later. We are now ready to display the information we have selected from the ClearSCADA database. 3.4 Displaying Database Information

Section 3 - Connecting to a Data Source

Issue 1.4

3-7

Crystal Reports XI Training Course

Now that we have selected the information we want to display on our report we are ready to preview it. Select View > Print Preview (alternatively click on the Print Preview button in the Standard toolbar or hit CTRL + R)

NOTE: During this course the menu options will be primarily used for accessing the required functionality. However nearly everything that can be accessed via the menus can also be accessed by the corresponding shortcut in the toolbars. Mousing over these shortcuts will display what they link to, and you will also notice that the icons displayed match the icons in the menus. You should be presented with a screen that looks similar to the following:

This is a list every point in our ClearSCADA database and the current value (formatted) associated with each one. NOTE: Some of the points have a blank value in the CurrentValueFormatted column. This most likely means that the point has either not being initialised or the device it is connected to is in a failed, offline or out-of-service state. Youll notice that this list isnt sorted alphabetically. That is because when a ClearSCADA database table is queried, the results are returned in order of

3-8

Issue 1.4

Section 3 - Connecting to a Data Source

Crystal Reports XI Training Course

Object Id. Each object in the ClearSCADA database has a unique identifier (Id) associated with it. Above the report preview on the right-hand side is a customised version of the Navigation toolbar. The white section in the middle of this toolbar should contain the text 1 of 1+. This indicates that the report contains multiple pages. Click on the single right-hand arrow to navigate to the next page. Click on the refresh button (or press F5) to refresh the data in the report. Note that some of the current values will change. Remember that Crystal Reports produces a snap-shot of the data in our system. Use ClearSCADA to access the up-to-date 'live' data in our system. Click on the right-hand arrow with a line next to it to navigate to the last page in our report. If you only have the example projects loaded and have not changed the default height of any of the report sections, there should be nine (9) pages of points.

NOTE: The Preview window can be closed at any time by clicking on the cross x next to the word Preview. We have now successfully created a Crystal Report, linked it to a table in our ClearSCADA database and displayed some specific information from this table (CDBPoint). Click on File > Save to store the report on disk. Save it with the file name Basic Report.rpt into a folder called Reports in My Documents (create the folder if necessary). The next chapter will introduce you to the concept of Record Selection through the use of the Select Expert tool, which allows the information queried to be subject to various selection criteria. As part of this a real-world Maintenance Report will be created and will be improved upon during following chapters. The chapter will also introduce the Crystal Reports driver embedded within ClearSCADA, which allows a smoother interface between the two software packages and explores the various techniques for exporting and displaying reports.

Section 3 - Connecting to a Data Source

Issue 1.4

3-9

Crystal Reports XI Training Course

3-10

Issue 1.4

Section 3 - Connecting to a Data Source

Crystal Reports XI Training Course

4 Record Selection
The previous chapter illustrated how to create a new Crystal Report, link it to an external data source, and display some simple information from that data source. The focus of this chapter is to introduce users to record selection techniques, allowing the information to be filtered based on various criteria. A real-world example report will be created during this chapter, which will be improved upon in future chapters. NOTE: At the end of any chapter if you have not completed a report that is required for the following chapter, a pre-completed copy of the report can be obtained and loaded from the training resources directory. In the previous chapter the report was created from within the Crystal Reports environment and saved to disk as a report file (.rpt). ClearSCADA has an integrated Crystal Reports driver that allows Crystal Report objects to be created and stored within its own database, and seamlessly generated or exported to all formats supported by Crystal Reports. The following section illustrates how to create and configure a Crystal Report from within the ClearSCADA environment. 4.1 Crystal Reports in ClearSCADA

We will now explore the interface between Crystal Reports and the ClearSCADA Crystal Reports driver. If the Crystal Reports application is still open, close it now. Save the report if you have made any changes since the last time it was saved. Click on the Start button and select All Programs > Control Microsystems ClearSCADA > ViewX (or run the ViewX shortcut on the desktop). After loading you should be presented with a screen that looks similar to below:

Section 4 - Record Selection

Issue 1.4

4-1

Crystal Reports XI Training Course

The first thing you may notice is a slightly irritating sound beeping at you if your computer has sound enabled. This is happening because there are active alarms in the Alarm Banner (which is located at the bottom of the screen above the Status Bar). These alarms are part of the ClearSCADA demo projects, so dont worry, we havent broken anything yet. If desired the sound can be temporarily disabled by right-clicking on the red rectangle on the left side of the Alarm banner and selecting Disable Bell. Within this rectangle the top number is the number of unacknowledged alarms in your area of the system (i.e. the alarms that you have permissions to view), and the bottom number is the total number of alarms in your area of the system. NOTE: The alarm bell can be enabled/disabled or the entire alarm banner can be removed on a per user basis. On the left-hand side of the ViewX window is the Database Explorer bar. This is where users can browse to, configure and view any object within the database (provided they have sufficient permission). Objects can be sorted into folder-like objects called Groups, which is useful for keeping related objects together, thus maintaining a highly cohesive database structure. Many standard Windows operations (such as copy and paste) are supported within this bar.

4-2

Issue 1.4

Section 4 - Record Selection

Crystal Reports XI Training Course

The database is configured with an example project that is imported as part of the ClearSCADA Demo installation. By default this example project has security enabled so that access is restricted. We will now log into our system so we have the required permissions to create and configure objects. Right-click on the word MAIN and select the Log On option. Enter Eng into the Username field and leave the Password field blank. User names and passwords are case-sensitive in ClearSCADA so ensure the case is correct. Click Ok. You should have a screen that looks similar to below:

NOTE: If the login fails it is likely that the example projects have not being imported. If this occurs right-click on the word MAIN and select Import & Merge. Navigate to the training resources directory, click on the Example Projects.sde file and select Open. Once logged in you will notice that the screen has changed. Within ViewX the toolbar, explorer bar, status bar and alarm banner arrangement is automatically saved on a per user basis. Within the Database Explorer bar click the plus icon next to the word MAIN to expand the database tree. If for any reason the Database Explorer bar isnt displayed, click View > Explorer Bar > Database. Click the plus icon next to the Example Projects group to expand it. Under this click the plus icon next to the ~Config group.

Section 4 - Record Selection

Issue 1.4

4-3

Crystal Reports XI Training Course

The ~Config folder (group) is often used to store project-specific configuration such as user accounts and groups, template objects, custom colors and symbols. Right-click on the group named ~Config and select New > Group > Group. Name the newly created group Reports and press Enter.

You should have a screen that looks similar to below:

This is where we will store our Crystal Reports objects. Right-click on the new group named Reports and select New > Other > Crystal Report. Name the newly created report Maintenance Report and press Enter.

We have now created a Crystal Report object within our ClearSCADA database, which is ready to be configured. Right-click on the new report named Maintenance Report and select Edit (or double click on it).

NOTE: The default action performed by double-clicking on an object is subject to the account configuration of the logged in user.

4-4

Issue 1.4

Section 4 - Record Selection

Crystal Reports XI Training Course

NOTE: Double clicking on any object within the Database Explorer bar in ViewX will perform the default action for that object. For example, double clicking on a Mimic type object will display it. The default action for a Crystal Report object is to edit it. The Crystal Reports editor will load. If an error message is displayed about the report using an invalid printer, click Ok to close it. Close the Business Object Registration Wizard or any Update dialogs that may appear.

We should now be left with a familiar looking blank report, which we will now configure to be a useful Maintenance Report. 4.2 Maintenance Report (Version 1)

Well now create a maintenance style report, which shows the number of device failures experienced in the system for the last 7 days. You will have noticed that the Database Expert was not automatically opened (as per creating a blank report from within Crystal Reports), so the first thing we need to do is link the report to a data source and select the table(s) we wish to display information from. Open the Database Expert by clicking Database > Database Expert (or right-click on Database Fields in the Field Explorer and select Database Expert). In the Available Data Sources frame click the plus icon next to the Create New Connection entry to expand it. From the options presented click the plus icon next to the ODBC (RDO) folder to expand it. Click the plus icon next to the ClearSCADA entry to expand it. If there is no ClearSCADA option you will need to create a new connection (refer to the steps in section 3.2). Scroll down until you find the table named CDBEventJournal.

The CDBEventJournal table, as the name would suggest, contains all of the event data stored in the ClearSCADA database. Simply put, events are records of occurrences on your system. Events are logged for user interaction with the system and for automatic system occurrences such as alarms, point updates & scheduled archiving. Click on the CDBEventJournal entry then click on the right arrow (or double click on the CDBEventJournal entry) to add the table to the Selected Tables list. Click Ok to close the Database Expert.

Section 4 - Record Selection

Issue 1.4

4-5

Crystal Reports XI Training Course

We now have a blank report, which is linked to the table, which stores all event data in our ClearSCADA database. The fields of interest are as follows: Field Severity Time Message Data Type String Time String Description Severity of the event. Time the event occurred. Message describing the event.

Within the Field Explorer click the plus icon next to the Database Fields entry to expand it. Under this you should see a CDBEventJournal entry. Click the plus icon next to the CDBEventJournal entry to expand it. Find the entry named Severity. Drag and drop it into the Details section of the report, towards the left-hand side. Find the entry named Time. Drag and drop it into the Details section of the report, on the right-hand side of the Severity field. Find the entry named Message. Drag and drop it into the Details section of the report, on the right-hand side of the Time field.

Your report should look similar to below:

Well now try to preview the data. Select View > Print Preview (alternatively click on the Print Preview button in the Standard toolbar or hit CTRL + R)

4-6

Issue 1.4

Section 4 - Record Selection

Crystal Reports XI Training Course

You will receive an error message saying Failed to retrieve data from the database. Click Ok and a more detailed error message will be displayed. The problem is that we have not specified time constraints for our Event Journal query. For a reasonable sized system that has been running for an extended period of time, the amount of event journal data can be in the order of several Gigabytes, and thus it is unreasonable to expect Crystal to query this data. NOTE: The length of time that event (and historic) data is kept on the ClearSCADA server is configurable in the Server Configuration > Global Parameters > Historic section. Data that becomes older than the time frame specified is automatically deleted from the server, thus it is important to archive regularly.

4.3

Select Expert

Well now use the Select Expert to filter the records based on a dynamic time period. Click Ok on any open error messages. Close the blank Preview window by clicking on the cross next to the word Preview. Select Report > Select Expert to open the Select Expert. In the Choose Field dialog select CDBEventJournal.Time from under Report Fields and click Ok.

The Select Expert dialog will now be open, ready to define the required criteria for the Time field. NOTE: The Select Expert can also be launched by right-clicking on a field and selecting Select Expert. In this case the Choose Field dialog is bypassed. Click on the drop-down box under the CDBEventJournal.Time tab. This drop-down menu lists all of the available selection criteria for the field chosen, and is context sensitive. Select the is in the period option. In the new drop-down box that appears, select Last7Days.

Your screen should look similar to below:

Section 4 - Record Selection

Issue 1.4

4-7

Crystal Reports XI Training Course

Click Ok.

We now have now added a time constraint, but on a large system the number of event records generated in a week may be in the order of hundreds of thousands. We will use the Select Expert to add another constraint to reduce the amount of data returned. Right-click on the Message field in the Details section of the report and choose Select Expert. You will notice a new tab within the Select Expert named CDBEventJournal.Message has been added next to the tab named CDBEventJournal.Time. Click on the drop-down box under the CDBEventJournal.Message tab and select the is like option. In the new drop-down box that appears enter the following text: *Device Failed*

NOTE: Database object names are case-sensitive, so care must be taken when typing strings to be matched to object names. Click the Add button. Click the Ok button.

The criteria we have added specifies that it must only select records where the Message field contains the string Device Failed. The * symbol is a

4-8

Issue 1.4

Section 4 - Record Selection

Crystal Reports XI Training Course

wildcard which means that * can be substituted with any number of other characters. We will now add a title to our report. Select Insert > Text Object (or right-click somewhere in the report and select Insert Text Object). Click and hold the mouse button down in the Report Header section and drag a rectangle shape. Release the mouse button when you are happy with the size. Type in the following text: <Your name>s 7 Day Report - Device Failures, replacing <Your name> with your name. Click off the text object to finish editing the text. Right-click on the newly created text object and select Format Text. Under the Font tab change the Size to 16. Under the Paragraph tab change the Alignment to Centered. Click Ok. Select View > Print Preview (alternatively click on the Print Preview button in the Standard toolbar or hit CTRL + R) and wait while the ClearSCADA database is queried.

NOTE: Crystal Reports caches the data returned in a query so that subsequent previews of the report will not cause unnecessary processing and network activity. At any time the report data can be refreshed by selecting Report > Refresh Report Data (or pressing F5). When the query has finished you should have a report that looks similar to below (you may have a lot less records):

Section 4 - Record Selection

Issue 1.4

4-9

Crystal Reports XI Training Course

There are a couple of things you will probably notice: The field widths are not formatted particularly well. When a field is dragged onto a report Crystal estimates how wide to make the field based on its data type, but this is not always accurate with real world data. The Message field tells us what the problem is but not what object the problem has occurred on. The records are sorted by the Time field in an ascending order. This ordering is not specified by Crystal, but simply the order in which the results from the ClearSCADA database were returned.

We will now format the fields to increase readability, add a new field to the report which shows us which object (or device) the event is associated with, and sort the records in a descending order of Time (so that the most recent failures are at the top of the report). Open the design tab by clicking on the word Design next to the Preview tab. Click File > Page Setup and change the Orientation to Landscape. This will give us more space to view an extra field.

4-10

Issue 1.4

Section 4 - Record Selection

Crystal Reports XI Training Course

NOTE: If no printers are detected the PC, use of the landscape option may cause an error displaying the data. If this occurs simply install a text printer via the Windows Control Panel. Click Ok to close the Page Setup. Within the Field Explorer find the entry named Source. Drag and drop it into the Details section of the report, in between the Time and Message fields. The Source fields is as follows: Field Source Data Type String Description Name of the object the event is associated with.

Reposition and resize the fields on the report until you can correctly see the data within each field (you may need to decrease the font size using the Formatting toolbar).

NOTE: Report fields can also be moved, resized and formatted in the Preview view of the report. This can be especially useful for getting the width of fields correct.

4.4

Record Sort Expert Select Report > Record Sort Expert to open the Record Sort Expert. In the Available Fields list select CDBEventJournal.Time from under Report Fields and click on the right arrow (or double click on the CDBEventJournal.Time entry) to add the field to the Sort Fields list. Make sure the Sort Direction is set to Descending.

NOTE: Crystal Reports allows multiple sort criteria. Click Ok.

If you arent already viewing the Preview tab, change to it now. Close any Explorer Bars open to increase the space for viewing our report. You should have a report that looks similar to below:

Section 4 - Record Selection

Issue 1.4

4-11

Crystal Reports XI Training Course

Well now save the changes we have made. Click on File > Save (or press CTRL + S) to save the report. You will notice that despite the fact we started with a blank report, no dialog is presented to choose where to save the report. This is because the report was linked from ClearSCADA, and is automatically saved back into the ClearSCADA database.

NOTE: In order to update a report in the ClearSCADA database, ViewX must remain running while the report is being edited in the Crystal Reports application. As each report must be saved using its original file name, it is advised that you always use the Save option in Crystal, rather than the Save As option, to store your reports.

If you wish to save a file copy of your report as well, click on File > Save As. Name the report Maintenance Report v1.rpt and save it in the Reports folder in My Documents (create the folder if necessary).

The next section will explore the generation and displaying of reports from within ClearSCADA. 4.5 Report Generation & Displaying

4-12

Issue 1.4

Section 4 - Record Selection

Crystal Reports XI Training Course

The Crystal Reports driver in ClearSCADA allows configured reports to be generated then either displayed in the built-in Crystal Report viewer, exported to disk in a specified file format (for example, PDF or CSV) or emailed to specified users. The following table shows each of the Crystal Reports specific actions available for reports in ClearSCADA: Action Display Export Report Description Displays a report that has been generated as an inset in the Crystal Reports viewer. Exports a report in the format and to the destination specified in the Crystal Report object properties. The report is produced on the fly and contains the latest data. Generates and stores a report on the server. The generated report will replace the previously generated version of the same report, unless the report is stored historically. Prints a copy of a report to a printer on your system. The report is produced on the fly and printed with the latest data.

Generate Report

Print Report

NOTE: The actions specified above may only become available within ClearSCADA after the report is appropriately configured. If the Crystal Reports application is still open, close it now. Make sure that ViewX is displaying. In the Database explorer bar make sure you can see the Maintenance Report object we created in section 4.1 (if you cant, make sure you are logged in with the Eng user and navigate to Example Projects > ~Config > Reports). Right-click on the Maintenance Report object and you will be presented with a context sensitive menu. Your screen should look similar to below:

Section 4 - Record Selection

Issue 1.4

4-13

Crystal Reports XI Training Course

Select the Generate Report option from the menu.

Once selected if you look down the bottom right of ViewX, the status bar should briefly contain the following message: Example Projects.~Config.Reports.Maintenance Report, Generate report requested

After a short time the following message should be displayed: Example Projects.~Config.Reports.Maintenance Report, Generate report request successful (<Date/Time>)

NOTE: The status bar in ViewX contains information such as the user currently logged in and the most recent event that has occurred in your system. In a large system with many events being generated the status bar will change frequently. If you missed either message in the status bar, right-click on the Maintenance Report object and select the Display Events option from the menu. This will bring up a window with a list of events specific to this object only. Selecting Items > Refresh (or pressing F5) will update the data in this list.

4-14

Issue 1.4

Section 4 - Record Selection

Crystal Reports XI Training Course

If any message other then the ones mentioned above are displayed, then ClearSCADA, the System DSN or the report is configured incorrectly. Please refer to troubleshooting section 16.1. NOTE: If the report generation fails with a Failed Logon error, the report may need to be tied to a user account. To do this right-click on the report object and select Properties. Under Data Source > User browse to the Users group, select Eng and click Ok. Save and close the report properties. Now that our report has been generated, we are ready to display it. Right-click on the Maintenance Report object and select the Display option from the menu. This will bring up an inset window with the report we generated. Your screen should look similar to below:

Maximise the viewer by clicking on the Maximise button at the top right of the window. Click on the drop-down size box and select a view size that clearly displays the information in the report. If your report has multiple pages confirm that other pages can be navigated to using the page navigation buttons.

Section 4 - Record Selection

Issue 1.4

4-15

Crystal Reports XI Training Course

We have now explored the generation and displaying of Crystal Reports from within ClearSCADA. The exporting and printing of reports from within ClearSCADA will be covered further in chapters to come. This ends the Record Selection chapter. The following points summarise what we have covered in this chapter: The interface between Crystal Reports and the ClearSCADA Crystal Reports driver. An introduction to ViewX, including logging into the server and navigating the Database tree. The creation of objects in the ClearSCADA database and executing methods on those objects. The Select Expert tool to define multiple record selection criteria. Creating text objects in a report. The Sort Expert tool to sort data based on specific criteria.

The following chapter covers the formatting of reports, which can improve readability and draw attention to important information.

4-16

Issue 1.4

Section 4 - Record Selection

Crystal Reports XI Training Course

5 Report Formatting
This chapter focuses on various techniques for modifying the layout and design of a Crystal Report. This includes the appearance of text and other objects. Report formatting can vastly improve the readability of a report and draw attention to key information. The following section improves upon the Maintenance Report created in the previous chapter. Remember that if you have not completed this report you can import the pre-completed report from the training resources directory. 5.1 Maintenance Report (Version 2)

In the previous chapter we touched on some simple formatting options, such as resizing a field box and changing its font size. We will now look at more of the formatting features available in Crystal Reports. Ensure that ViewX is open in front of you. If it isnt click on the Start button and select All Programs > Control Microsystems ClearSCADA > ViewX. Ensure you are logged in as the Eng user account. In the Database explorer bar navigate to Example Projects > ~Config > Reports.

Well now create a copy of the maintenance report created in the previous chapter so we can keep (and compare) the original report. Click on the Maintenance Report object to ensure it is highlighted. Select Edit > Copy (or press CTRL + C). Select Edit > Paste (or press CTRL + V). Right-click on the newly created report and select Rename. Call the report Maintenance Report v2. Rename the existing Maintenance Report object to Maintenance Report v1 if you are like me and will lose sleep over this slight naming discrepancy. Right-click on Maintenance Report v2 and select Edit (or double click on it) to open the report for editing in Crystal Reports.

Once Crystal Reports has opened you should see the report we created in the previous chapter. Well now make some cosmetic changes and add some more information to it in an effort to increase its usefulness. Right click on the title text object in the Report Header and select Format Text. Under the Border tab in the Line style section, change each drop-down box to Single. Under the Border tab check the tick-box next to the words Drop Shadow.

Section 5 - Report Formatting

Issue 1.4

5-1

Crystal Reports XI Training Course

5.2

Under the Border tab check the tick-box next to the word Background and select a light color like silver. Click Ok to close the Format Editor. Inserting Picture Objects

We will now add a picture object into the header of our report. This is a common location for a company logo. Select Insert > Picture. A dialog will open to select a file. Navigate to the training resources directory and click on the file named ClearSCADA Icon (64x64).bmp. Click Open.

The dialog will close and an orange box should appear next to the mouse cursor. Hover the cursor over the left-hand side of the Report Header section and click to place the picture into the report (dont worry if it doesnt look like it will fit, the header will automatically be resized). Use the dragging handles on the corner of the object to resize it if it looks blurry.

NOTE: Resizing images in the report view does not allow you to maintain the aspect ratio, however if the image is right-clicked on under Format Graphic > Picture the image can be resized manually to maintain the ratio.

5.3

Inserting Special Fields

We will now add a sub heading under our main heading to display the date and time that the report was generated. Click on the line that separates the Report Header section and the Page Header section and increase the Report Header section by dragging the line down. Select Insert > Text Object (or right-click somewhere in the report and select Insert Text Object). Click and hold the mouse button down in the Report Header section and drag a rectangle shape under the report title. Release the mouse button when you are happy with the size. Type in the following text: Report Generated: . Click off the text object to finish editing the text. In the Field Explorer click the plus icon next to the Special Fields entry to expand it. Find the entry named Print Date and drag and drop it into the text object created above, on the right-hand side.

5-2

Issue 1.4

Section 5 - Report Formatting

Crystal Reports XI Training Course

Find the entry named Print Time and drag and drop it into the text object created above, to the right of the Print Date entry.

NOTE: Entries from the Field Explorer can be dragged into text objects in a report and are appended to them. Right-click on the Report Generated text object and select Format Text. Under the Font tab change the Color drop-down box to Blue and check the Underline tick-box. Under the Paragraph tab change the Alignment to Centered. Click Ok to close the Format Editor. Adjust and resize the Report Header and the objects in it to look neat.

Some of the special fields use information pulled from the report itself. This information can be set by the report user by selecting File > Summary Info. 5.4 Inserting a Page Footer

Well now add some summary information to our Page Footer. In the Field Explorer under Special Fields find the entry named Page N of M and drag and drop it into the middle of the Page Footer section. Right-click on this field select Format Field. Under the Common tab change the Horizontal Alignment to Centered. Click Ok to close the Format Editor. Select View > Print Preview (or press CTRL + R) to preview the report. Your report should look similar to below:

Section 5 - Report Formatting

Issue 1.4

5-3

Crystal Reports XI Training Course

5.5

Highlighting

It is common that there is information in a report such as the one we have created thus far that is more important to us than the rest. Say for example that a failure of Well Head No 2 has critical consequences for the local oil and gas agency. We may wish to highlight this information to quickly bring any problems with Well Head No 2 to our attention. Well now use the Highlighting Expert, which allows us to apply conditional formatting to any of our report fields. Switch back to the design tab by clicking on the word Design next to the Preview tab (if the Preview is still open). Right-click on the Source field in the Details section of the report and select Highlighting Expert. Click on the New button. In the Item Editor click on the blank drop-down box under the dropdown box that says is equal to and select Example Projects.Oil and Gas.Extraction.Well Head No 2.RTU.Device Failure from the options presented.

NOTE: If no drop-down box is available, please ensure the print preview view of the report is still open.

5-4

Issue 1.4

Section 5 - Report Formatting

Crystal Reports XI Training Course

NOTE: If Well Head No 2 does not appear in the drop-down list it simply means that the device has not failed since the database was loaded. Just choose another device. Change the Font color to Red and the Background to Yellow. Click Ok to close the Highlighting Expert. Switch back to the Preview tab to review your changes. Your report should look similar to below:

This highlighting quickly tells us that there is a critical problem in our system (and that we should probably be avoiding the local oil and gas agency). Select File > Save (or press CTRL + S) to save the report back into our database. You may have noticed that not all of the string matching options presented in the highlighting expert were available (e.g. the Is Like option). Advanced string matching and highlighting can be achieved through the use of formulas (covered later in chapter 13). Exercises 1. Export the report to a Microsoft Word (RTF) document from within ClearSCADA Crystal Report Viewer (Hint: Try the button in the top left of the viewer). 2. Export the report to a HTML page.

Section 5 - Report Formatting

Issue 1.4

5-5

Crystal Reports XI Training Course

This ends the Report Formatting chapter. The following points summarise what we have covered in this chapter: Further formatting of the appearance of a text box. Inserting picture objects. Concatenating fields with existing text objects. The Special Fields. The Highlighting Expert.

The following chapter introduces the concept of grouping data.

5-6

Issue 1.4

Section 5 - Report Formatting

Crystal Reports XI Training Course

6 Group Selection
This chapter introduces users to the concept of grouping data. Grouped data is data that is sorted and broken up into meaningful groups. We will be using the Group Expert tool within Crystal Reports to specify how fields will be grouped on our report. 6.1 Predictive Maintenance Report (Version 1)

For this chapter we will be creating a blank report. The report will display the hourly runtime information reported for the pump objects in our system. If the Crystal Reports application is still open, close it now. Save the report if you have made any changes since the last time it was saved. Ensure that ViewX is open in front of you. If it isnt click on the Start button and select All Programs > Control Microsystems ClearSCADA > ViewX. Ensure you are logged in as the Eng user account. In the Database explorer bar navigate to Example Projects > ~Config > Reports. Right-click on the group named Reports and select New > Other > Crystal Report. Name the newly created report Predictive Maintenance Report and press Enter. Right-click on the new report named Predictive Maintenance Report and select Edit (or double click on it).

The Crystal Reports editor will open and we will have a blank report ready to be edited. We will be adding two (2) tables to this report, namely the Runtime Accumulator table (CAccumulatorRunTime) and a preconfigured Historic View (HisHourlyMaximum). In ClearSCADA, an Accumulator calculates or increments its value, depending on the state or value of another Accumulator or point (known as its source). A Runtime Accumulator calculates the amount of time that its source is in a True or False state during a specified period. Historic Views allow applications to access the historic data stored in ClearSCADA at uniform intervals. Each Historic View represents a type of calculation and a time period (referred to as the historic sample), and is a table in the database. You can use the Historic Views within SQL queries to allow both ClearSCADA and third party applications to read historic values for specific time periods. Open the Database Expert by clicking Database > Database Expert (or right-click on Database Fields in the Field Explorer and select Database Expert).

Section 6 - Group Selection

Issue 1.4

6-1

Crystal Reports XI Training Course

In the Available Data Sources frame click the plus icon next to the Create New Connection entry to expand it. From the options presented click the plus icon next to the ODBC (RDO) folder to expand it. Click the plus icon next to the ClearSCADA entry to expand it. If there is no ClearSCADA option you will need to create a new connection (refer to the steps in section 3.2). Scroll down until you find the table named CAccumulatorRunTime. Click on it then click on the right arrow (or double click on the CAccumulatorRunTime entry) to add the table to the Selected Tables list. Scroll down further until you find the table named HisHourlyMaximum. Click on it then click on the right arrow (or double click on the HisHourlyMaximum entry) to add the table to the Selected Tables list. Click Ok. You will be presented with a screen that looks similar to below:

It is common that a database containing multiple tables has fields that are linked between tables, so that records from one table match related records from another. If Crystal Reports detects that there are related fields when multiple tables are selected it will automatically create a link between these fields. These link(s) can be reviewed and changed if required.

6-2

Issue 1.4

Section 6 - Group Selection

Crystal Reports XI Training Course

The link between the Id fields is correct, so click the Ok button to close the Database Expert.

We will now populate the report with the fields we are interested in. Within the Field Explorer click the plus icon next to the Database Fields entry to expand it. Under this you should see a CAccumulatorRunTime entry and a HisHourlyMaximum entry. Click the plus icon next to the HisHourlyMaximum entry to expand it. Find the entry named RecordTime. Drag and drop it into the Details section of the report, towards the left-hand side. Find the entry named Value. Drag and drop it into the Details section of the report, on the right-hand side of the RecordTime field. Group Expert

6.2

We will now use the Group Expert to group our data by the accumulator that measures the hourly runtime for each pump. Select Report > Group Expert to launch the Group Expert tool. In the Available Fields list click the plus icon next to the CAccumulatorRunTime entry to expand it. Find the entry named FullName. Click on it then click on the right arrow (or double click on the FullName entry) to add the field to the Group By list. Click Ok to close the Group Expert. Your screen should look similar to below:

Section 6 - Group Selection

Issue 1.4

6-3

Crystal Reports XI Training Course

A new section has been added to the report named Group Header #1 and a new field named Group #1 Name has automatically been added within this section. Increase the width of the Group #1 Name field to the width of the page by clicking on the field and using the resize handle on the right-hand side.

Before we can preview the information in our report we must add some constraints. We will quickly add a few constraints now. Click on the RecordTime field in the Details section of the report. Select Report > Select Expert to open the Select Expert. Click on the drop-down box under the HisHourlyMaximum.RecordTime tab and select the is in the period option. In the new drop-down box that appears, select Last7Days.

We will also limit our report to only display the runtime information for our Oil and Gas Well Heads. Click on the New tab next to the HisHourlyMaximum.RecordTime tab. In the Choose Field dialog that appears select CAccumulatorRunTime.FullName and click Ok. Click on the drop-down box under the CAccumulatorRunTime.FullName tab and select the is like option.

6-4

Issue 1.4

Section 6 - Group Selection

Crystal Reports XI Training Course

In the new drop-down box that appears enter the following text: *Oil and Gas*, ensuring that the case is correct. Click the Add button. Click the Ok button to close the Select Expert.

Before we preview our report quickly add a title to the Page Header section. Enter the text Oil and Gas - Hourly Pump Runtimes and make it an appropriate size and alignment. Select View > Print Preview (or press CTRL + R) to preview the report. Your report should look similar to below:

As you scroll down and view other pages you will notice there are a lot of blank values. This is due to the fact there is not history recorded for every hour in the last week. Well now spend a bit of time improving the appearance of our report. Open the design tab by clicking on the word Design next to the Preview tab. Click on the Value field in the Details section of the report. Select Report > Select Expert to open the Select Expert. Click on the drop-down box under the HisHourlyMaximum.Value tab and select the is not equal to option. In the new drop-down box that appears enter the number 0. Click the Ok button to close the Select Expert.

We will also neaten up the formatting of our RecordTime field.

Section 6 - Group Selection

Issue 1.4

6-5

Crystal Reports XI Training Course

Right-click on RecordTime field in the Details section of the report and select Format Field. In the Date and Time tab press the Customize button to open the Custom Style dialog. In the Date tab under Format change the Day to 01. In the Time tab select the 24 Hour radio button and change the Hour option to 05. Click Ok. Click Ok to close the Format Editor.

The positioning of the page headings is slightly confusing. We can move them to be in the group heading, under the primary heading. Increase the size of the Group Header #1 section by clicking on the line between it and the Details section and dragging it down. Drag the RecordTime and Value headings into Group Header #1 under the Group #1 Name.

Some other things you may like to change to improve the overall appearance of the report: Double click on the RecordTime heading and rename it to Date/Time. Double click on the Value heading and rename it to Runtime (Seconds). Resize the field if required. Format the title to have a box. Change the font and color. Insert the ClearSCADA logo to the Report Header (Hint: see section 5.2). Add a sub-title for when the report was generated (Hint: see section 5.3). Add a report footer showing the number of pages (Hint: see section 5.4).

Preview your report until you are happy with its appearance. Your report may look something like this:

6-6

Issue 1.4

Section 6 - Group Selection

Crystal Reports XI Training Course

The formatting changes made drastically increase the readability of the report. This ends the Group Selection chapter. The following points summarise what we have covered in this chapter: Selecting multiple database tables and verifying the links between them. The Accumulator objects and Historic Views in ClearSCADA. The Group Expert. Review of multiple selection criteria. Review of report formatting.

The following chapter introduces the concept of summary fields and improves upon the Predictive Maintenance Report created in this chapter.

Section 6 - Group Selection

Issue 1.4

6-7

Crystal Reports XI Training Course

6-8

Issue 1.4

Section 6 - Group Selection

Crystal Reports XI Training Course

7 Summary Fields
This chapter introduces users to Summary fields in reports. Summary fields (as the name suggests) allow users to summarise data and print the summary in your report. They can be used for such things as; counting the number of values in a group, calculating the sum, average, standard deviation, or variance value in a group or identifying the minimum or maximum value in a group. 7.1 Predictive Maintenance Report (Version 2)

The Predictive Maintenance Report created in the previous chapter will be used as a starting point for this chapter. The report will be improved on by adding a new group and additional summary information. If the Crystal Reports application is still open, close it now. Save the report if you have made any changes since the last time it was saved. Ensure that ViewX is open in front of you. If it isnt click on the Start button and select All Programs > Control Microsystems ClearSCADA > ViewX. Ensure you are logged in as the Eng user account. In the Database explorer bar navigate to Example Projects > ~Config > Reports.

Well now create a copy of the predictive maintenance report created in the previous chapter so we can keep (and compare) the original report. Click on the Predictive Maintenance Report object to ensure it is highlighted. Select Edit > Copy (or press CTRL + C). Select Edit > Paste (or press CTRL + V). Right-click on the newly created report and select Rename. Call the report Predictive Maintenance Report v2. Rename the existing report to Predictive Maintenance Report v1 if you wish. Right-click on Predictive Maintenance Report v2 and select Edit (or double click on it) to open the report for editing in Crystal Reports.

One of the things that could be criticised about this report is that due to the amount of information displayed for each pump (hourly data), it is not obvious immediately if there are any system problems until each page of the report is checked. We will add a new group to our report to group the hourly data into daily data. Select Report > Group Expert. In the Available Fields list under Report Fields find the entry named HisHourlyMaximum.RecordTime. Click on it then click on the right

Section 7 - Summary Fields

Issue 1.4

7-1

Crystal Reports XI Training Course

arrow (or double click on the HisHourlyMaximum.RecordTime entry) to add the table to the Group By list. NOTE: Crystal Reports allows multiple group selection criteria. The records are grouped in a top down order and the sorting type for each grouping criteria can be configured separately. In the Group By list click on the entry named HisHourlyMaximum.RecordTime. Click on the Options button. Change the drop-down box under the HisHourlyMaximum.RecordTime drop-down box from in ascending order to in descending order. Change the drop-down box under The section will be printed to for each day. Click Ok. Your screen should look similar to below:

A new section has been added to the report named Group Header #2 and a new field named Group #2 Name has automatically been added within this section. This will group the data returned firstly into unique device names in ascending order, then within that group by 24 hour periods. We can use Summary fields in conjunction with the Crystal Reports Drill-down feature to show only summarised data.

7-2

Issue 1.4

Section 7 - Summary Fields

Crystal Reports XI Training Course

7.2

Inserting a Summary

We will now insert a summary field into our report. The field will be placed in our 2nd Group Header. NOTE: Summary fields are most often placed in either the Report Footer or Group Footer sections, but can be placed anywhere in the report. Select Insert > Summary. In the drop-down box under Choose the field to summarize ensure that HisHourlyMaximum.Value is selected. In the drop-down box under Calculate this summary select Sum. In the drop-down box under Summary location select Group #2: HisHourlyMaximum.RecordTime. Click Ok.

A new summary field will have been placed in the Group Footer #2 section. However, we want this field in the Group Header. Click on the newly added summary field in the Group Footer #2 section and drag it into the Group Header #2 section. Reposition and resize the fields in Group Header #2 if required. Format the Group #2 Name field so the Date/Time format matches the other RecordTime field. Select View > Print Preview (or press CTRL + R) to preview your report. Your report may look something like this:

Section 7 - Summary Fields

Issue 1.4

7-3

Crystal Reports XI Training Course

At the top of each day group entry (shown in bold) is the date and the total runtime of the pump for the day, in seconds. The report is starting to look professional, but we still havent reduced the amount of information displayed for each pump runtime object. We will now use the Drill Down feature of Crystal to achieve this. 7.3 Drill Down

Crystal Reports allows you to drill down on group or summary information when viewing a report in the Preview tab. This allows detailed information to be hidden and only viewed when required. The drilling options are unique to each section of the report. Open the design tab by clicking on the word Design next to the Preview tab. Right-click where it says Details on the left of the report and select the Hide (Drill-Down OK) option. This option hides the information within the associated section of the report until it is displayed when previewing the report. Right-click where it says Group Footer #2 on the left of the report and select the Suppress (No Drill-Down). This option hides the information within the associated section of the report, and cannot be viewed when previewing the report. Reposition and resize the Group #2 Name field until it lines up with the associated heading.

7-4

Issue 1.4

Section 7 - Summary Fields

Crystal Reports XI Training Course

Remove the Bold option from the fields in the Group Header #2. Rename the main title in the Report Heading to Oil and Gas - Daily Pump Runtimes. Preview your report again to review the changes. Your report may look something like this:

Because we enabled drill down on our Group Header #2 section, double click on one of the Date/Time entries. This will open a new Preview window with the hourly data for that particular pump. You should have a screen similar to below:

Section 7 - Summary Fields

Issue 1.4

7-5

Crystal Reports XI Training Course

Will we now insert a box around each pump object to make the distinction between each one more clear. 7.4 Inserting a Box

Crystal Reports allows simple box shapes to be added to reports. These boxes can span multiple sections allowing grouped data to be easily distinguished. Open the design tab by clicking on the word Design next to the Preview tab. Select Insert > Box. Click and drag the cursor from the top left of Group Header #1 (within the body of the report) to the bottom right of Group Footer #1 (be careful that the box doesnt span into neighboring sections). Click to place the box. Right-click on the newly created box and select Format Box. In the Box tab change the Color to Blue. In the Rounding tab change the Rounding to 2%. Click Ok.

We will also insert a simple line to break up the headings in Group Header #1.

7-6

Issue 1.4

Section 7 - Summary Fields

Crystal Reports XI Training Course

7.5

Inserting a Line Select Insert > Line. Click and drag the cursor from the left side of box in the previous section to the right-hand side of the box, splitting Group #1 Name from the other headings. Click to place the line. Right-click on the newly created box and select Format Line. In the Line tab change the Color to Blue. Click Ok. Preview your report. It should look similar to below:

This report is now fairly easy on the eye, and quickly illustrates if there is any problems with our Oil and Gas pumps (assuming the data for a 24 hour period is complete). This ends the Summary Fields chapter. The following points summarise what we have covered in this chapter: Multiple group selection criteria. Custom sorting and printing options for grouped sections. Inserting summary fields. Drill-down options. Inserting a box. Inserting a line.

Section 7 - Summary Fields

Issue 1.4

7-7

Crystal Reports XI Training Course

The following chapter introduces users to the charting feature of Crystal Reports, to further increase the usefulness of data and make it easy to interpret.

7-8

Issue 1.4

Section 7 - Summary Fields

Crystal Reports XI Training Course

8 Charts
Crystal Reports allow users to present summarised data in colorful, easy-toread charts. This section demonstrates how to create charts and how to use them in reports to make report data more meaningful and easier to understand. There are a number of chart layouts and types, as well as drill down (discusses in the previous chapter) to see the details behind the graphical summaries and format chart objects. 8.1 Predictive Maintenance Report (Version 3)

The Predictive Maintenance Report modified in the previous chapter will be used as a starting point for this chapter. The report will be improved on by adding a chart to which quickly displays the running times for each pump over the past week. If the Crystal Reports application is still open, close it now. Save the report if you have made any changes since the last time it was saved. Ensure that ViewX is open in front of you. If it isnt click on the Start button and select All Programs > Control Microsystems ClearSCADA > ViewX. Ensure you are logged in as the Eng user account. In the Database explorer bar navigate to Example Projects > ~Config > Reports.

Well now create a copy of the predictive maintenance report created in the previous chapter so we can keep (and compare) the original reports. Click on the Predictive Maintenance Report v2 object to ensure it is highlighted. Select Edit > Copy (or press CTRL + C). Select Edit > Paste (or press CTRL + V). Right-click on the newly created report and select Rename. Call the report Predictive Maintenance Report v3. Right-click on Predictive Maintenance Report v3 and select Edit (or double click on it) to open the report for editing in Crystal Reports. Insert Chart

8.2

Charts in a Crystal Report are typically based on summary information at the group level of a report. NOTE: Charts cannot be placed in the Details section of a report. We will be placing our chart in Group Footer #1.

Section 8 - Charts

Issue 1.4

8-1

Crystal Reports XI Training Course

Increase the size of the Group Footer #1 section by clicking on the line between it and the Details section and dragging it down. Use the dragging handles on the bottom of the box object outlining our information, and increase its size downwards. Select Insert > Chart. Hover the cursor over the blank space created in Group Footer #1 and click to place the chart into the report (dont worry if it doesnt look like it will fit, the footer will automatically be resized). Right-click on the chart and select Chart Expert. You will presented with a screen that looks similar to below:

In the Type tab leave the chart type as Bar. Check the Use depth effect tick-box. Select the Data tab. Ensure the layout is set to Group. Select the Axes tab. In the Data Values section, uncheck the tick-box under Auto range and set the Max to 86400. In the Number of divisions section, set the Data axis to Manual and enter a value of 8. Select the Text tab. In the Titles section, uncheck each of the Auto-Text tick-boxes. Set the Title to Pump Runtime per Day, Group title to Date and Data title to Runtime (s). In the Format section click the Font button and change the size to 12. Click Ok. Click Ok to close the Chart Expert.

Our chart is now configured with the data desired.

8-2

Issue 1.4

Section 8 - Charts

Crystal Reports XI Training Course

Use the dragging handles on the sides of the chart object and increase its width to be the width of the report, just inside the box. If you like, add another Line object above the chart to separate the chart from the details above it. Format both Line objects to be Dotted (right-click on the line and select Format Line, then Line > Style > Dotted) Preview your report. It should look similar to below:

Exercises 1. Configure the chart to be a stacked line graph instead of a bar graph. This ends the Charts chapter. The following points summarise what we have covered in this chapter: Inserting a chart. Modifying the appearance of a chart.

The following chapter runs through a review of the concepts covered thus far.

Section 8 - Charts

Issue 1.4

8-3

Crystal Reports XI Training Course

8-4

Issue 1.4

Section 8 - Charts

Crystal Reports XI Training Course

9 Day 1 Review
This chapter serves as a review of the material covered during the first day of the course. A review Crystal Report will be created and concepts from each chapter will be incorporated into the report. 9.1 Day 1 Review Report

Use the following steps to create a Day 1 Review report. Open ViewX, log in as the Eng user, and navigate to Example Projects.~Config.Reports in the Database Explorer bar. Create a new Crystal Report object and name it Day 1 Review. Open the report for editing. Use the Database Expert to link to the ClearSCADA database and add the CDBPoint table. Add the following fields to the Details section of your report: Id, Name, CurrentValueFormatted and CurrentQualityDesc. Use the Select Expert to only return records that are NOT of type Internal Digital Point. Use the Group Expert to group records by TypeDesc in descending order. Insert a box around the group. Insert a report heading, a picture, the report generation date and the page number into the appropriate section of the report. Use the Highlighting Expert to highlight the Name of points that have a CurrentQualityDesc of anything other than Good. Insert a summary field into the group header to display the number of points in each group. Insert a pie chart into the group footer to display the CurrentQualityDesc of the points in each group. Format your report with colors and font styles to make it more appealing to the eye. Preview your report. It should look vaguely similar to below:

Section 9 - Day 1 Review

Issue 1.4

9-1

Crystal Reports XI Training Course

For any hints, the design mode view of the report is also shown below:

9-2

Issue 1.4

Section 9 - Day 1 Review

Crystal Reports XI Training Course

This ends the Day 1 Review chapter. The following points summarise what we have covered in this chapter: Review of creating database objects in ClearSCADA. Review of editing reports in Crystal Reports. Review of linking a Crystal Report to a ClearSCADA data source. Review of specifying record selection criteria. Review of various report formatting techniques, including field appearance editing, picture objects, special fields, report headers/footers and highlighting. Review of group selection allowing logical grouping of report data. Review of summary fields. Review of charts.

The following chapter introduces the concept of adding Parameter fields to reports, allowing further flexibility, and how ClearSCADA can make use of these parameters.

Section 9 - Day 1 Review

Issue 1.4

9-3

Crystal Reports XI Training Course

9-4

Issue 1.4

Section 9 - Day 1 Review

Crystal Reports XI Training Course

10 Parameterized Reports
Parameters are Crystal Reports fields that allow you to collect input from the report user and run the report based on the input. These parameters can be used in formulas, selection formulas and in the report itself to specify various criteria such as the color of the text in the report, or the time range that the returned data must fall between for example. Parameter fields can also be used in subreports (see chapter 14). Generally, when a report with at least one parameter is generated, a prompt will be displayed. Prompts are elements that help users set a value for report parameters. ClearSCADA, through the use of pick-actions, can automatically pass parameter values into a report during a generation request. A parameter can be static or dynamic. A static prompt is one that always contains the same available values. For example, if your parameter prompts for a ClearSCADA object type, you could create a static prompt and only allow object types specified. A dynamic prompt is one that changes dynamically based on some form of data source. For example, if you are prompting for a point type, you could create a dynamic prompt with a list of only the point types that currently exist in your ClearSCADA database. Well now create a production style report, which shows the daily maximum, minimum and average gas flow volumes over a period of time specified with Parameter Fields. 10.1 Production Report (Version 1) For this chapter we will be creating a blank report. The report will display the daily maximum, minimum and average values for the gas flow volumes in each of the well heads configured in our system. If the Crystal Reports application is still open, close it now. Save the report if you have made any changes since the last time it was saved. Ensure that ViewX is open in front of you. If it isnt click on the Start button and select All Programs > Control Microsystems ClearSCADA > ViewX. Ensure you are logged in as the Eng user account. In the Database explorer bar navigate to Example Projects > ~Config > Reports. Right-click on the group named Reports and select New > Other > Crystal Report. Name the newly created report Production Report and press Enter. Right-click on the new report named Production Report and select Edit (or double click on it).

Section 10 - Parameterized Reports

Issue 1.4

10-1

Crystal Reports XI Training Course

The Crystal Reports editor will open and we will have a blank report ready to be edited. We will be adding two (2) tables to this report, namely the Internal Analog Point (CPointAlgManual) and a preconfigured Historic View (HisDailyMinMaxAverage). Open the Database Expert by clicking Database > Database Expert (or right-click on Database Fields in the Field Explorer and select Database Expert). In the Available Data Sources frame click the plus icon next to the Create New Connection entry to expand it. From the options presented click the plus icon next to the ODBC (RDO) folder to expand it. Click the plus icon next to the ClearSCADA entry to expand it. If there is no ClearSCADA option you will need to create a new connection (refer to the steps in section 3.2). Scroll down until you find the table named CPointAlgManual. Click on it then click on the right arrow (or double click on the CPointAlgManual entry) to add the table to the Selected Tables list. Scroll down further until you find the table named HisDailyMinMaxAverage. Click on it then click on the right arrow (or double click on the HisDailyMinMaxAverage entry) to add the table to the Selected Tables list. Click Ok. The default Links are correct, so click Ok to close the Database Expert.

We will now populate the report with the fields we are interested in. Within the Field Explorer under the Database Fields entry, click to expand HisDailyMinMaxAverage entry. Find the entry named Summary. Drag and drop it into the Details section of the report, towards the left-hand side. Find the entry named Value. Drag and drop it into the Details section of the report, on the right-hand side of the Summary field.

We will now add two (2) Parameter Fields to our report, allowing the input of 2 date/time values. These values will be used to determine the timeframe within which the historic values must fall between. 10.2 Inserting Parameter Fields In the Field Explorer right-click on Parameter Fields and select New. You will be presented with a dialog similar to below:

10-2

Issue 1.4

Section 10 - Parameterized Reports

Crystal Reports XI Training Course

Enter Start Date for the Name of the parameter. Set the Type to be Date Time. Review the other options, but the default values are fine. Click Ok. Create another parameter field of type Date Time named End Date.

Well now use these Parameters in the Select Expert to specify the time frame for data returned in out historic query. Click in a blank area of the report to ensure neither of the fields dragged on are selected (if a field is selected the Select Expert bypasses the Choose Field step). Select Report > Select Expert to open the Select Expert. In the Choose Field dialog select HisDailyMinMaxAverage.RecordTime from under ClearSCADA (ODBC (RDO)) and click Ok. Click on the drop-down box under the HisDailyMinMaxAverage.RecordTime tab and select the is between option. In the new drop-down boxes displayed, set the top one to {?Start Date} and the bottom one to {?End Date}. These expressions will be dynamically converted to the date values passed into the report when generated. Select the <New> tab to add another selection criterion.

Section 10 - Parameterized Reports

Issue 1.4

10-3

Crystal Reports XI Training Course

In the Choose Field dialog select CPointAlgManual.Name from under ClearSCADA (ODBC (RDO)) and click Ok. Click on the drop-down box under the CPointAlgManual.Name tab and select the is equal to options. In the new drop-down box displayed type in the word "GasFlow" (with no quotes), ensuring the case is correct. Click the Show Formula button to view the formula created. It should look the same as below:

Click Ok to close the Select Expert.

Well now create two (2) groups for our data, to group records by each individual point, and then values for each day within the dates entered via the parameters. Select Report > Group Expert to launch the Group Expert tool. In the Available Fields list click the plus icon next to the CPointAlgManual entry to expand it. Find the entry named FullName. Click on it then click on the right arrow (or double click on the FullName entry) to add the table to the Group By list. In the Available Fields list click the plus icon next to the HisDailyMinMaxAverage entry to expand it. Find the entry named RecordTime. Click on it then click on the right arrow (or double click on the RecordTime entry) to add the table to the Group By list. Click on the newly added HisDailyMinMaxAverage.RecordTime entry and select the Options button.

10-4

Issue 1.4

Section 10 - Parameterized Reports

Crystal Reports XI Training Course

Change the drop-down box under The section will be printed to for each day. Click Ok. Click Ok to close the Group Expert. Your screen should look similar to below:

All of the core components for a meaningful report are now present. Use the following steps as a guide to formatting the report to make it both easier to interpret and visually pleasing, but feel free to customise any of the steps to suit your own taste. Reposition and resize the field Group #1 Name to be nearly the width of the page. Turn off bold and increase the font size to 12. Reposition and resize the field Group #2 Name. Turn off bold, increase the font size to 12 and change the font color to be blue. Rename the Value heading field to be Gas Flow Volume. Move both the Summary and Gas Flow Volume heading fields into the Group Header #2 section, below Group #2 Name. Create and format a box that goes from Group Header #1 to Group Footer #1. Create and format a line between Group #1 Name and Group Header #2. Create and format a suitable report heading. Add a Report Time Frame text object under the report heading, and drag the two (2) parameter fields into it.

Section 10 - Parameterized Reports

Issue 1.4

10-5

Crystal Reports XI Training Course

Add a suitable image to the Report Header. Add suitable Report Footer(s). Suppress Group Footer #2.

Preview your report. When prompted for parameters make sure a sensible time frame is chosen. If the time frame is too large the report preview will fail as the Historic Cache size limit will be met. This is a measure in place to ensure queries do not use all of a servers available memory. Your report should look vaguely similar to below:

NOTE: If you always get blank results, try making the end date parameter the day after the current date. This will ensure that the daily values for the current day are also included. For any hints, the design mode view of the report is also shown below:

10-6

Issue 1.4

Section 10 - Parameterized Reports

Crystal Reports XI Training Course

We will now illustrate how ClearSCADA detects if a Crystal Report has parameters configured, and will prompt for them during generation. 10.3 Parameters from ClearSCADA If the Crystal Reports application is still open, close it now. Make sure that ViewX is running and on display. In the Database explorer bar make sure you can see the Production Report object we created in section 10.1 (if you cant, make sure you are logged in with the Eng user and navigate to Example Projects > ~Config > Reports). In the same group (Reports) there should be a mimic named Default. If there isnt a mimic named Default right-click on the Reports group and select New > Mimic.

NOTE: When a new Group object is created, a mimic named Default is created within the group automatically. Right-click on the mimic and select Edit (or double click on the mimic and ensure it is in Design mode). In the Database explorer bar, click on the Production Report object and drag the mouse over the open mimic. The icon should change to

Section 10 - Parameterized Reports

Issue 1.4

10-7

Crystal Reports XI Training Course

show a + symbol when a drop location is valid. Release the mouse button and a context sensitive menu will be displayed. NOTE: When objects are dragged and dropped onto a mimic, the list of options available dynamically changes based on the type of object being dragged on. Select the Name option. The name of the report should be displaying within this tag. Drag and drop the report onto the mimic again to the right of the Name tag, and select the Status option.

Well now add two (2) buttons to our mimic, which will be configured to generate and display the report. Select Insert > Button (or click on the Button icon in the Mimic Editing toolbar). The icon will have changed to a crosshair. Click and hold the mouse button down on the mimic to the right of the Status tag and drag a rectangle shape. Release the mouse button when you are happy with the size. Right-click on the newly created button and select Properties (or double click on the button object). Under the General tab in the Button section, change the Text from Button to Generate. Click on the Pick Action button.

NOTE: A pick action is an action that is executed when a user clicks on the mimic item on which the action has been configured. Select Method for the type of pick action and click Next. Click on the browse button next to the Object field. In the Select Object dialog navigate to Example Projects > ~Config > Reports group (if not already), click on the Production Report object and click Ok. From the Method drop-down box select the Generate Report option and click Next. Note that ClearSCADA has detected the Parameters configured in the report. We will leave the fields blank so that ClearSCADA will prompt for the parameter values when generated. Click Next. Enter the text Generate Report for the pick action comment and click Next. Click Finish to close the pick action wizard. Create another button to the right of the Generate button. Open the button properties and configure the Text to be Display. Run the pick action wizard and enter the following details: o Type: Hyperlink o URL: Production Report object

10-8

Issue 1.4

Section 10 - Parameterized Reports

Crystal Reports XI Training Course

o Mode: Open In New Window o Pick action comment: Display Report Click Finish to close the pick action wizard. Select File > Save (or press CTRL + S) to save the changes to the mimic.

Your mimic should now look something like this:

Place the mimic in run mode by selecting View > Design (or clicking the Design icon in the File toolbar). Click on the Generate button. A dialog will be displayed to enter values for the reports parameters. Choose a reasonable time frame for the data (1 or 2 days) and click Ok.

Note that the status tag will update as the report is being generated. The report is ready to be displayed when the status returns to Idle. If the status changes to Failed, then something has gone wrong. Click on the status tag and select Display Events. Find the error message in the event list and consult Crystal Reports troubleshooting section (16.1) to find a resolution. Click the Display button to open the generated report in the Crystal Reports Viewer. You may need to adjust the zoom level to be able to read the data values.

Section 10 - Parameterized Reports

Issue 1.4

10-9

Crystal Reports XI Training Course

The date parameters can also be calculated at a regular interval and automatically passed into our report via a button click. Select View > Design to put the mimic back into design mode. Create another button under the Generate button. Open the button properties. Click on the Animations in the General tab. Double click on the Text property to enter an expression. Click on the browse button to the right of the Expression field and select OPC Tag. In the Select Tag browser navigate to the following location:

MAIN > Root Group > Example Projects > ~Config > Logic > Report Dates > Time Frame (Days) > Find the CurrentValue property, highlight it and select Ok. Carefully add the following text: o Before the expression: Generate ( + str( o After the expression: ) + days) The final expression should look similar to below:

10-10

Issue 1.4

Section 10 - Parameterized Reports

Crystal Reports XI Training Course

NOTE: The + operator concatenates strings, and the str function converts and data result into a string format. Click Ok to close the Expression editor. Click Close to close the Animations dialog. Run the pick action wizard and enter the following details: o Type: Method o Object: Production Report object o Method: Generate Report

You will now be presented with the parameters again that we left blank in the previous exercise. This time double click on each parameter and browse to the following OPC Tags respectively: Example Projects > ~Config > Logic > Report Dates > Start > CurrentValue Example Projects > ~Config > Logic > Report Dates > End > CurrentValue The window should look the same as below:

Section 10 - Parameterized Reports

Issue 1.4

10-11

Crystal Reports XI Training Course

o Pick action comment: Auto-Generate Report Click Finish to close the pick action wizard.

Note the text on the new button. It should say Generate (2 days). This is a dynamic animation based on the value of another object in the database. NOTE: If the button says Generate ( days) it is because the point used for calculating the button text has not been set with a value. Select File > Save (or press CTRL + S) to save changes to the mimic. Place the mimic in run mode by selecting View > Design (or clicking the Design icon in the File toolbar). Click on the Generate (2 days) button and note that no dialog will be displayed prompting for the reports parameters.

Exercises 1. Within ViewX, Hand Control the time frame analog point (located at Example Projects.~Config.Logic.Report Dates.Time Frame (Days)) to four (4). Make sure the logic that maps the time points has executed, and verify that the report displays the additional information when regenerated (albeit blank). This ends the Parameterized Reports chapter. The following points summarise what we have covered in this chapter: Creating and configuring Parameter fields in Crystal Reports.

10-12

Issue 1.4

Section 10 - Parameterized Reports

Crystal Reports XI Training Course

Using Parameter fields as part of report selection criterion. Passing parameter values into reports generated from within ClearSCADA, both manually and automatically. Creating tags and buttons on mimic objects. Configuring dynamic animations. Using the pick action wizard to execute actions on objects from a button click.

The following chapter introduces users more formally to Report Sections.

Section 10 - Parameterized Reports

Issue 1.4

10-13

Crystal Reports XI Training Course

10-14

Issue 1.4

Section 10 - Parameterized Reports

Crystal Reports XI Training Course

11 Report Sections
Crystal Reports provides five primary design areas to use when building reports, namely the Report Header, Page Header, Details, Report Footer and Page Footer. Each area contains a single section when you first create a new report. These original sections cannot be deleted but can be hidden or split into multiple sections. We have already used nearly all of these sections in previous chapters and, through the use of the Group Expert, created multiple Group Header and Footer sections. The aim of this chapter is to illustrate some of the finer details of using report sections. 11.1 Production Report (Version 2) In the previous chapter we created a production report to display daily gas flow volume details. We will now attempt to enhance the appearance of the report by applying some advanced section formatting. Ensure that ViewX is open in front of you. If it isnt click on the Start button and select All Programs > Control Microsystems ClearSCADA > ViewX. Ensure you are logged in as the Eng user account. In the Database explorer bar navigate to Example Projects > ~Config > Reports.

Well now create a copy of the production report created in the previous chapter so we can keep (and compare) the original report. Click on the Production Report object to ensure it is highlighted. Select Edit > Copy (or press CTRL + C). Select Edit > Paste (or press CTRL + V). Right-click on the newly created report and select Rename. Call the report Production Report v2. Rename the existing Production Report object to Production Report v1 if you wish. Right-click on Production Report v2 and select Edit (or double click on it) to open the report for editing in Crystal Reports.

Once Crystal Reports has opened you should see the report we created in the previous chapter. Well now add a new section to the report, and modify the behaviour and appearance of the sections.

Section 11 - Report Sections

Issue 1.4

11-1

Crystal Reports XI Training Course

11.2 Section Expert Select Report > Section Expert. You will be presented with a dialog that looks similar to below:

NOTE: If page real estate is a problem the section names can be truncated by right-clicking on any of the section names and selecting Show Short Section Names (e.g. Page Header will display as PH). You may have noticed in the previous chapter that the group of data for each Well Head may have been split over 2 pages. This can be avoided by printing each group on a new page. In the Sections frame, click on Group Header #1. Check the New Page Before tick-box.

The New Page Before option causes the first page to be mainly blank, but this space could be used for a full page corporate title page or to contain useful summary information. Click Ok to close the Section Expert. Preview the report and check that each group is printed on a new page.

11-2

Issue 1.4

Section 11 - Report Sections

Crystal Reports XI Training Course

NOTE: You may notice that most of the Common options have an X+2 button next to it. This means that the section behaviour can be controlled by a formula. This is covered in more detail in Chapter 13. Well now add some color to both the page header and footer to make the page edges stand out more. Select Report > Section Expert. In the Sections frame, click on Page Header. Click on the Color tab and check the Background Color tick-box. Leave the color as Silver. Do the same for the Page Footer. Click Ok to close the Section Expert. Preview the report to confirm the changes.

You will have noticed that Group Header #2 contains two (2) sets of headings, one for the date, and one for the Summary and Gas Flow Volume. Well now split Group Header #2 into two distinct sections. Select Report > Section Expert. In the Sections frame, click on Group Header #2. Press the Insert button. Note that we now have two group headers, #2a and #2b. Click Ok to close the Section Expert. Drag and drop the Summary and Gas Flow Volume headings into Group Heading #2b. Resize Group Header #2a to remove the empty space. Preview the report and ensure the group headers look as expected.

This splitting of the section allows individual formatting options to be applied to each group header. If it is decided that the split in the sections is no longer required, the two sections can be merged together. Select Report > Section Expert. In the Sections frame, click on Group Header #2a. Press the Merge button. Note we are back to having only Group Header #2. Click Ok to close the Section Expert. Check that no tags have been lost during the merge. Your report (in design view) should look similar to below:

Section 11 Report Sections

Issue 1.4

11-3

Crystal Reports XI Training Course

NOTE: Sections can not only be added and merged, but also moved and deleted. Remember to be careful, especially when deleting sections with report fields, as they will also be deleted with the section. This ends the Report Sections chapter. The following points summarise what we have covered in this chapter: Formatting individual sections using the Section Expert. Adding new sections to the report. Merging sections.

The following chapter introduces users to Report Templates.

11-4

Issue 1.4

Section 11 - Report Sections

Crystal Reports XI Training Course

12 Report Templates
A template is an existing report file whose formatting can be added to a new report. Report Templates are a quick and efficient means of applying standardised formatting to multiple reports. Crystal Reports comes with a set of professionally-designed report templates, which can be applied to any report, but also allows users to create their own customised templates to suit their needs. The aim of this chapter is to illustrate both the usage of existing Report Templates and also the creation of new templates. 12.1 Production Report (Version 3) In the previous chapter we modified the appearance of our production report using the Section Expert. We will now attempt to enhance the appearance of the report by applying a preconfigured template. Ensure that ViewX is open in front of you. If it isnt click on the Start button and select All Programs > Control Microsystems ClearSCADA > ViewX. Ensure you are logged in as the Eng user account. In the Database explorer bar navigate to Example Projects > ~Config > Reports.

Well now create a copy of the production report modified in the previous chapter so we can keep (and compare) the original reports. Click on the Production Report v2 object to ensure it is highlighted. Select Edit > Copy (or press CTRL + C). Select Edit > Paste (or press CTRL + V). Right-click on the newly created report and select Rename. Call the report Production Report v3. Right-click on Production Report v3 and select Edit (or double click on it) to open the report for editing in Crystal Reports.

Once Crystal Reports has opened you should see the report we created in the previous chapter. Well now apply a preconfigured template to it. 12.2 Template Expert Select Report > Template Expert. You will be presented with a dialog that looks similar to below:

Section 12 - Report Templates

Issue 1.4

12-1

Crystal Reports XI Training Course

In the Available Templates frame click on each of the templates to view a Preview of it.

NOTE: Not all of the preconfigured templates can be applied to a report without losing information, so care must be taken when selecting one. Select the Confidential Underlay template and click Ok to close the Template Expert. In Group Header #1 resize Group #1 Name to be the width of the page. Preview the report. Your report should look similar to below:

12-2

Issue 1.4

Section 12 - Report Templates

Crystal Reports XI Training Course

It is fairly easy to see how quickly the appearance of a report can be modified using report templates. NOTE: A template can be removed by opening the Template Expert and selecting the Undo the current template option. We will now create our own report template. 12.3 Creating a Report Template Crystal Reports has the ability the allow reports to be created without them needing to be linked to a data source. The use of Template Object Fields allows report objects to be created without referring to any database fields. These fields are simply inserted and formatted as desired, and when the template is applied to another report, Crystal Reports displays that reports data with the formatting specified. Template Field Objects can only be applied to result fields (database fields, parameter fields, SQL expression fields and formulas). Make sure the Crystal Reports application is open. If it isnt, click on the Start button and select All Programs > BusinessObjects 11 > Crystal Reports > Crystal Reports 11. Close any dialogs that may open.

Section 12 - Report Templates

Issue 1.4

12-3

Crystal Reports XI Training Course

Click File > New > Blank Report (or click on the Blank Report link under the New Reports heading on the Start Page). The Database Expert will appear. Click Cancel, as we do not need to link the report to a data source.

We will now have a blank report, ready to be formatted with Template Object Fields. 12.4 Inserting a Template Field Object Select Insert > Template Field Object. Hover the mouse over the Details section of the report on the left-hand side and click to place the field. Resize the width of the field to be approximately two thirds the width of the page. Select Insert > Template Field Object. Hover the mouse over the Details section of the report on the righthand side of the other field and click to place the second field. Highlight both fields by clicking on the report and dragging over both fields, or by holding down CTRL and clicking on each field (make sure you only highlight the fields in the Details section). Right-click on one of the highlighted fields and select Format Template Fields. In the Font tab: o Set the Font to Tahoma (or some other font). o Set the Style to Bold. o Set the Color to something pretty. Click Ok to close the Format Editor. Highlight both of the automatically generated heading fields by clicking on the report and dragging over both fields, or by holding down CTRL and clicking on each field. Right-click on one of the highlighted fields and select Format Objects. In the Border tab: o Check the tick-box next to Background. o Set the Background color to Red. In the Font tab: o Set the Font to Tahoma (or some other font). o Set the Style to Bold. Click Ok to close the Format Editor. Your report should look similar to below:

12-4

Issue 1.4

Section 12 - Report Templates

Crystal Reports XI Training Course

Click on File > Save to store the report on disk. Save it with the file name Report Template.rpt into a folder called Reports in My Documents. We will now apply our newly created template to the Basic Report we created in Chapter 3. Select File > Open. Navigate to the location of the file Basic Report.rpt, select it and click Open. Select Report > Template Expert. Click on the Browse button to find our report template. Navigate to the location of the file Report Template.rpt, select it and click Open. Click Ok to close the Template Expert. Preview the report if you arent already doing so. Your basic report should now similar to below:

Section 12 - Report Templates

Issue 1.4

12-5

Crystal Reports XI Training Course

You can easily see how quickly formatting can be applied to existing reports through the use of report templates. If you would like to save a copy of this report click on File > Save As and change the file name to Basic Report v2.rpt. This ends the Report Templates chapter. The following points summarise what we have covered in this chapter: Applying pre-existing report templates to any report. Creating and configuring new report templates.

The following chapter introduces users to the creation and usage of formulas in reports.

12-6

Issue 1.4

Section 12 - Report Templates

Crystal Reports XI Training Course

13 Creating Formulas
Generally when creating reports, most of the data required for the report already exists in database table fields. For example, a report may need to list each of the points configured in the database, grouped by point type, and display the current state and value associated with each one. This can easily be achieved with the database fields provided by ClearSCADA. Sometimes however, the report will require data that does not exist in any of the data fields. In such cases a formula is required. For example, a report may need to list each of the points configured in the database, grouped by point type, and display the current state, previous state and the amount of time since the last state change associated with each one. In this example the amount of time since the last state change must be calculated. The following are some common uses for formulas in Crystal Reports: Creating calculated fields to add to your report. Formatting text on a report. Pulling out a portion, or portions, of a text string. Extracting parts of a date or time. Using custom functions.

We will now create a device status summary report that illustrates the usage of formulas in reports. The report will show information from a subset of the points within our ClearSCADA database, including the current and previous state and the time since the state last changed. 13.1 Device Status Summary Report For this chapter we will be creating a blank report. The report will display device status information for each device in our system. If the Crystal Reports application is still open, close it now. Save the report if you have made any changes since the last time it was saved. Ensure that ViewX is open in front of you. If it isnt click on the Start button and select All Programs > Control Microsystems ClearSCADA > ViewX. Ensure you are logged in as the Eng user account. In the Database explorer bar navigate to Example Projects > ~Config > Reports. Right-click on the group named Reports and select New > Other > Crystal Report. Name the newly created report Device Status Summary and press Enter. Right-click on the new report named Device Status Summary and select Edit (or double click on it).

Section 13 - Creating Formulas

Issue 1.4

13-1

Crystal Reports XI Training Course

The Crystal Reports editor will open and we will have a blank report ready to be edited. We will be adding one (1) table to this report, namely the Abstract Point table (CDBPoint). The CDBPoint table contains a lot of general information that is common to all variations of points in the database, including the current/previous value, current/previous quality and current/previous state. Open the Database Expert by clicking Database > Database Expert (or right-click on Database Fields in the Field Explorer and select Database Expert). In the Available Data Sources frame click the plus icon next to the Create New Connection entry to expand it. From the options presented click the plus icon next to the ODBC (RDO) folder to expand it. Click the plus icon next to the ClearSCADA entry to expand it. If there is no ClearSCADA option you will need to create a new connection (refer to the steps in section 3.2). Scroll down until you find the table named CDBPoint. Click on it then click on the right arrow (or double click on the CDBPoint entry) to add the table to the Selected Tables list. Click Ok to close the Database Expert.

We will now populate the report with the fields we are interested in. Within the Field Explorer click the plus icon next to the Database Fields entry to expand it. Click the plus icon next to the CDBPoint entry to expand it. Find the entry named CurrentStateDesc. Drag and drop it into the Details section of the report, towards the left-hand side. Find the entry named PreviousStateDesc. Drag and drop it into the Details section of the report, on the right-hand side of the CurrentStateDesc field. Find the entry named CurrentTime. Drag and drop it into the Details section of the report, on the right-hand side of the PreviousStateDesc field. Rename the field headings to Current State, Previous State and Last Updated respectively.

NOTE: The CurrentTime field is actually the time the points value was last updated, and the PreviousTime field is the time the points value was updated before that. Well now use the Select Expert to filter the records based on points with a specific name. Select Report > Select Expert to open the Select Expert. In the Choose Field dialog that appears select CDBPoint.Name and click Ok.

13-2

Issue 1.4

Section 13 - Creating Formulas

Crystal Reports XI Training Course

Click on the drop-down box under the CDBPoint.Name tab and select the is equal to option. In the new drop-down box that appears enter the following text: Device Failure, ensuring that the case is correct. Click the Ok button to close the Select Expert.

Well now add a formula field to extract the device name from the full name of the points returned. 13.2 Inserting Formula Fields In the Field Explorer right-click on Formula Fields and select New. Enter the Name: Device Name and click Ok. You will be presented with a dialog similar to below:

The Formula Editor contains the following main sections (clockwise from the top-left, ignoring the left frame): Field Explorer: lists the report fields, database fields, parameter fields, formula fields and any other predefined fields. Function Explorer: lists the available built-in Crystal Report functions that are available when writing formulas. Operator Explorer: lists the built-in Crystal Reports operators that are available when writing formulas.

Section 13 - Creating Formulas

Issue 1.4

13-3

Crystal Reports XI Training Course

Code Section: the editor area where programmable information is typed.

NOTE: While working in the code section, CTRL + SPACE can be pressed at any time to bring up the function explorer. Enter the following text into the code section:
//Declare evaluation time. WhileReadingRecords; //Declare local Local StringVar Local StringVar Local NumberVar variables. Array aDeviceName; sOutput; nArraySize;

//Perform calculations. aDeviceName := Split({CDBPoint.FullName}, "."); nArraySize := 4; If (UBound(aDeviceName) >= nArraySize) Then sOutput := aDeviceName[4] Else sOutput := "*** Name Error ***"; //Return output. sOutput;

The following table explains what the various lines of the code mean:
Line //<text> Meaning The <text> is a comment often used to indicate what the formula is doing at that point. Comments are ignored by the compiler. This line tells the environment to calculate the value of the field while it is reading the records. Declares a variable. The syntax is <scope> <type> <name>. Splits the FullName value of the point into an array of values, delimited by a full stop. These values are stored in a local variable defined earlier. Checks if the size of the array is big enough to pull out the piece of information we want. Assigns the 4th element of the array into a local variable defined earlier. Returns to value of the variable to the report.

WhileReadingRecords;

Local StringVar Array aDeviceName aDeviceName := Split({CDBPoint.FullName}, ".");

If (UBound(aDeviceName) >= nArraySize) Then

sOutput := aDeviceName[4] sOutput;

The syntax and structure of the code is very similar to that of Visual Basic, and can in fact be changed from Crystal Syntax to Basic Syntax if you prefer that format.

13-4

Issue 1.4

Section 13 - Creating Formulas

Crystal Reports XI Training Course

NOTE: The Crystal Report help contains a complete function reference defining what each one does, what parameters are available, and an example of its usage (see Help > Crystal Reports Help > Functions). At any time the code in the formula can be checked for errors by clicking the x+2 button (but errors will automatically be detected if the formula is saved). Click Save and close to close the Formula Editor.

We now have a formula that calculates the device name associated with our Device Failure point by extracting part of its full name. Now we will group our data based on this value. Select Report > Group Expert to launch the Group Expert tool. In the Available Fields list find the formula entry named Device Name (it will have an x+1 icon next to it). Click on it then click on the right arrow (or double click on the Device Name entry) to add the field to the Group By list. Click Ok to close the Group Expert. Your screen should look similar to below:

We will now create another formula to calculate the number of hours since the last state change for our devices.

Section 13 - Creating Formulas

Issue 1.4

13-5

Crystal Reports XI Training Course

In the Field Explorer right-click on Formula Fields and select New. Enter the Name: Time Since State Change and click Ok. Enter the following text into the code section:
//Declare evaluation time. WhileReadingRecords; //Declare local variables. Local DateTimeVar dLastUpdated; Local DateTimeVar dCurrentDateTime; Local NumberVar nSecondsDiff; Local StringVar sOutput; Local NumberVar nTempSeconds; Local NumberVar nTempMinutes; Local NumberVar nTempHours; //Perform calculations. dLastUpdated := {CDBPoint.CurrentTime}; dCurrentDateTime := CurrentDateTime; nSecondsDiff := DateDiff ("s", dLastUpdated, dCurrentDateTime); If nSecondsDiff < 0 Then sOutput := "Never updated" Else If nSecondsDiff < 60 Then sOutput := CStr(nSecondsDiff) & " seconds" Else If nSecondsDiff / 60 < 60 Then sOutput := CStr(nSecondsDiff / 60) & " minutes" Else sOutput := CStr(nSecondsDiff / 3600) & " hours"; //Return output. sOutput;

Click Save and close to close the Formula Editor. Drag and drop the newly created formula field into the Details section of the report, on the right-hand side of the CurrentTime field. Preview your report and check that the values are correct. The report should look similar to below:

13-6

Issue 1.4

Section 13 - Creating Formulas

Crystal Reports XI Training Course

Exercises 1. Create an Internal Digital Point in the root of the ClearSCADA database and call it Device Failure. Ensure the report correctly handles the situation where the device name isnt structured as we expect. 2. Change the If-Then-Else control structure of the Time Since State Change formula to instead use a Select Case control structure. 3. [Advanced] Change the formula to always show the exact number of hours, minutes and seconds (e.g. 2h, 17m, 35s). This ends the Creating Formulas chapter. The following points summarise what we have covered in this chapter: Creating formula fields in Crystal Reports. Configuring formula fields with various built-in functions.

The following chapter introduces users to the creation and usage of subreports.

Section 13 - Creating Formulas

Issue 1.4

13-7

Crystal Reports XI Training Course

13-8

Issue 1.4

Section 13 - Creating Formulas

Crystal Reports XI Training Course

14 Subreports
A subreport is essentially a report within a report. Supreports allow unrelated reports to be combined into a single report. Unlinked data or data from different data sources can be co-ordinated and presented in different views in a single report. To summarise, typically there are four (4) situations in which a subreport would be used: To combine unrelated reports into a single report. To co-ordinate data that cannot otherwise be linked. To present different views of the same data within a single report. To perform one-to-many lookups from a field that is not indexed on the lookup field.

The process for creating a subreport is similar to the process of creating a regular report. A subreport can have most of the characteristics of a report, including its own record selection criteria. The differences between a subreport and a primary report are that a subreport: Is inserted as an object into a primary report; it cannot stand on its own (although a subreport can be saved as a primary report). Can be placed in any report section and the entire subreport will print in that section. Cannot contain another subreport. Does not have Page Header or Page Footer sections.

For this chapter we will create blank Master report, which will contain subreports to various other useful reports. 14.1 Master Report If the Crystal Reports application is still open, close it now. Save the report if you have made any changes since the last time it was saved. Ensure that ViewX is open in front of you. If it isnt click on the Start button and select All Programs > Control Microsystems ClearSCADA > ViewX. Ensure you are logged in as the Eng user account. In the Database explorer bar navigate to Example Projects > ~Config > Reports. Right-click on the group named Reports and select New > Other > Crystal Report. Name the newly created report Master Report and press Enter. Right-click on the new report named Master Report and select Edit (or double click on it).

The Crystal Reports editor will open and we will have a blank report ready to be edited.

Section 14 - Subreports

Issue 1.4

14-1

Crystal Reports XI Training Course

14.2 Inserting Subreports Select Insert > Subreport. The following dialog will be displayed:

We will now quickly create a subreport with the Report Wizard. Under the field New report name enter the text Point Alarms. Click the Report Wizard button. Use the following information to create the subreport: o Selected Tables: CDBPoint. o Fields to Display: CDBPoint.FullName. o Group By: None. o Filter Fields: CDBPoint.AlarmState > 1. NOTE: Refer to the database schema at the following location to see exactly what we have specified above: http://localhost/schema/CAlarmObject. o Template: No Template. Click Ok to close the Insert Subreport dialog. Place the Subreport in the Report Header section.

We now have an embedded Subreport within a master report. The master report itself is not linked to any specific data source.

14-2

Issue 1.4

Section 14 - Subreports

Crystal Reports XI Training Course

Right-click on the newly added Subreport and select Edit Subreport. Extend the width of the FullName field to the width of the page and rename the heading to Point Alarms. Remove the Print Date field. Use the Section Expert to merge the Report Header and Report Footer sections. Add a Summary Field to include the total number of alarms in the Point Alarms heading. Suppress any blank sections. Your Subreport should look similar to below:

Preview your report. Check that the number of alarms listed matches the number in the alarm banner in ViewX.

Exercises 1. Add a heading, image and the report generation date/time to the report header section of the Master Report. 2. Add another Subreport to the Master Report in the Report Footer section, this time choose an existing report (from disk) and make the subreport On-demand (hyperlink). 3. Link the Master Report to the CDBObject table and display the Name of each object in the database relative to its depth, for example the object ~Config.Comms.Channel would be seen as - - Channel.

Section 14 - Subreports

Issue 1.4

14-3

Crystal Reports XI Training Course

(Hint: Use a formula to find the depth of the object in the database tree with its FullName, and then use that depth to calculate the string including the objects Name). 4. Modify the Point Alarms Subreport so that the color of the text for the FullName field is different depending on exactly what alarm state the point is in (Hint: The Font color will need to be based on a formula). Your finished report should look something like this:

14-4

Issue 1.4

Section 14 - Subreports

Crystal Reports XI Training Course

For any hints, the design mode of the report is below:

Section 14 - Subreports

Issue 1.4

14-5

Crystal Reports XI Training Course

This ends the Subreports chapter. The following points summarise what we have covered in this chapter: Inserting a subreport, both from an existing file and creating a subreport on the fly. Modifying the appearance of a subreport. Review of formulas, summary fields and general report editing.

14-6

Issue 1.4

Section 14 - Subreports

Crystal Reports XI Training Course

15 Comments
Thank you for completing the Crystal Reports XI training course. Any feedback on the course content, course structure or presentation style is greatly valued. Please make any comments below:

Section 15 - Comments

Issue 1.4

15-1

Crystal Reports XI Training Course

15-2

Issue 1.4

Section 15 - Comments

Crystal Reports XI Training Course

16 Troubleshooting
16.1 Failed to generate a Crystal Report Check what the error message is in the event list for the report (or if an error pops up in a dialog) and use the following table to diagnose and fix the problem:
Problem Failed Logon Error Displayed Generate report request failed - Failed to generate report, Logon Failed... Resolution Ensure the user configured to generate the report has sufficient security permissions to allow them to access the required part of the system and check that the user is still valid in the system. Ensure that the configured System DSN matches the name of the DSN configured in ClearSCADA (Server Configuration > Global Parameters > Crystal Reports). Ensure sufficient constraints are placed on the data set being requested. For example, when querying the CDBHistoric table it is important to constrain the query by time. Check that the names of any tables used in the report match the names in ClearSCADA database schema. Occurs if the Crystal Reports driver is not running or not running correctly. Contact your support representative.

Incorrect DSN Configuration

'Generate report request failed - Failed to generate report, Failed to open the connection...'

Data Not Constrained

"Generate report request failed - Failed to generate report, Failed to retrieve data from the database..."

Table Not Found

"Generate report request failed - Failed to generate report, The table '' could not be found..." "InvokeMethod returns 0XC0140026. No interface to driver."

No Interface to Driver

Section 16 - Troubleshooting

Issue 1.4

16-1

Crystal Reports XI Training Course

16-2

Issue 1.4

Section 16 - Troubleshooting

Crystal Reports XI Training Course

17 Definitions/Abbreviations
Term Business Intelligence Meaning Business intelligence (BI) is a broad category of applications and technologies for gathering, providing access to, and analysing data for the purpose of helping enterprise users make better business decisions. Comma-Separated Value Distributed Network Protocol Data Source Name Local Area Network Open DataBase Connectivity OLE for Process Control Portable/Printable Document Format Public Switched Telephone Network Remote Data Object Supervisory Control And Data Acquisition Structured Query Language Wide Area Network

CSV DNP3 DSN LAN ODBC OPC PDF PSTN RDO SCADA SQL WAN

Section 17 - Definitions/Abbreviations

Issue 1.4

17-1

Crystal Reports XI Training Course

17-2

Issue 1.4

Section 17 - Definitions/Abbreviations

You might also like