Creating An OS Report With PH Data: SIMATIC PCS 7 / Process Historian
Creating An OS Report With PH Data: SIMATIC PCS 7 / Process Historian
with PH data
Siemens
Industry
SIMATIC PCS 7 / Process Historian Online
Support
https://support.industry.siemens.com/cs/ww/en/view/109770734
Legal information
Legal information
Use of application examples
Application examples illustrate the solution of automation tasks through an interaction of several
components in the form of text, graphics and/or software modules. The application examples are
a free service by Siemens AG and/or a subsidiary of Siemens AG ("Siemens"). They are
non-binding and make no claim to completeness or functionality regarding configuration and
equipment. The application examples merely offer help with typical tasks; they do not constitute
customer-specific solutions. You yourself are responsible for the proper and safe operation of the
products in accordance with applicable regulations and must also check the function of the
respective application example and customize it for your system.
Siemens grants you the non-exclusive, non-sublicensable and non-transferable right to have the
application examples used by technically trained personnel. Any change to the application
examples is your responsibility. Sharing the application examples with third parties or copying the
application examples or excerpts thereof is permitted only in combination with your own products.
The application examples are not required to undergo the customary tests and quality inspections
of a chargeable product; they may have functional and performance defects as well as errors. It is
your responsibility to use them in such a manner that any malfunctions that may occur do not
result in property damage or injury to persons.
Disclaimer of liability
Siemens shall not assume any liability, for any legal reason whatsoever, including, without
limitation, liability for the usability, availability, completeness and freedom from defects of the
application examples as well as for related information, configuration and performance data and
any damage caused thereby. This shall not apply in cases of mandatory liability, for example
under the German Product Liability Act, or in cases of intent, gross negligence, or culpable loss of
life, bodily injury or damage to health, non-compliance with a guarantee, fraudulent
non-disclosure of a defect, or culpable breach of material contractual obligations. Claims for
damages arising from a breach of material contractual obligations shall however be limited to the
© Siemens AG 2019 All rights reserved
foreseeable damage typical of the type of agreement, unless liability arises from intent or gross
negligence or is based on loss of life, bodily injury or damage to health. The foregoing provisions
do not imply any change in the burden of proof to your detriment. You shall indemnify Siemens
against existing or future claims of third parties in this connection except where Siemens is
mandatorily liable.
By using the application examples you acknowledge that Siemens cannot be held liable for any
damage beyond the liability provisions described.
Other information
Siemens reserves the right to make changes to the application examples at any time without
notice. In case of discrepancies between the suggestions in the application examples and other
Siemens publications such as catalogs, the content of the other documentation shall have
precedence.
The Siemens terms of use (https://support.industry.siemens.com) shall also apply.
Security information
Siemens provides products and solutions with Industrial Security functions that support the secure
operation of plants, systems, machines and networks.
In order to protect plants, systems, machines and networks against cyber threats, it is necessary
to implement – and continuously maintain – a holistic, state-of-the-art industrial security concept.
Siemens’ products and solutions constitute one element of such a concept.
Customers are responsible for preventing unauthorized access to their plants, systems, machines
and networks. Such systems, machines and components should only be connected to an
enterprise network or the Internet if and to the extent such a connection is necessary and only
when appropriate security measures (e.g. firewalls and/or network segmentation) are in place.
For additional information on industrial security measures that may be implemented, please visit
https://www.siemens.com/industrialsecurity.
Siemens’ products and solutions undergo continuous development to make them more secure.
Siemens strongly recommends that product updates are applied as soon as they are available
and that the latest product versions are used. Use of product versions that are no longer
supported, and failure to apply the latest updates may increase customer’s exposure to cyber
threats.
To stay informed about product updates, subscribe to the Siemens Industrial Security RSS Feed
at: https://www.siemens.com/industrialsecurity.
Table of contents
Legal information ..................................................................................................... 2
1 Introduction .................................................................................................... 4
1.1 Benefits of accessing the Process Historian ....................................... 6
1.2 Report requirement ............................................................................ 6
2 Create ODBC data source .............................................................................. 7
3 Example SQL database queries ................................................................... 11
3.1 Database views that can be used for PH database queries .............. 11
3.2 Determine Tag UIDs in the Process Historian Database................... 11
3.3 Read tag values............................................................................... 12
Read the latest value from the PH archive ....................................... 12
3.4 Reading Aggregated Values ............................................................ 12
3.4.1 Read minute aggregates.................................................................. 12
3.4.2 Read daily aggregates ..................................................................... 13
3.5 Read messages............................................................................... 13
4 WinCC report generation ............................................................................. 15
5 Create a WinCC Print Job ............................................................................ 19
5.1 Printing reports via the OS Runtime ................................................. 21
6 Report Example ............................................................................................ 22
© Siemens AG 2019 All rights reserved
7 Appendix....................................................................................................... 23
7.1 Service and support ......................................................................... 23
7.2 Links and literature .......................................................................... 24
7.3 Change documentation .................................................................... 24
1 Introduction
Core contents of the Application Example
The Process Historian is the long-term archive of a PCS 7 system. The Process
Historian data is stored in a SQL Server database. The stored data of the Process
Historian can be accessed using the Information Server or the PCS 7 OS Trend
and Alarm Control.
The application example explains how to create a PCS 7 OS Report with WinCC
Report Designer, which displays data from the Process Historian. This is especially
interesting for systems that use a PH but not an IS.
Validity:
• SIMATIC Process Historian 2014 SP3
In combination with:
• SIMATIC PCS 7 V8.0 SP2
• SIMATIC PCS 7 V8.1
• SIMATIC PCS 7 V8.2
• SIMATIC PCS 7 V9.0
Requirement
• The experienced handling of the PCS 7 OS and the WinCC Report Designer
© Siemens AG 2019 All rights reserved
Uses
• PDF report creation for attachments that do not use an information server.
• Direct creation of reports from the WinCC Runtime environment.
NOTE For detailed information about the WinCC Report Designer, please refer to the
chapter "Documentation of Configuration and Runtime Data" in the "WinCC
Information System".
© Siemens AG 2019 All rights reserved
NOTE Due to PCS 7 Engineering changes, the TagUIDs in the Process Historian
database may change. As a result, the WinCC Report must be adapted.
NOTE This application example was created with a PCS 7 OS Single Station V 9.0 SP1
and a Process Historian 2014 SP3 Upd3.
Operating system OS Single Station = Microsoft Windows Server 2012 R2
Standard
Operating System Process Historian = Microsoft Windows Server 2012 R2
Standard
1. You can display variables from all servers that store data on the PH.
2. Messages can be displayed from all servers that store data on the PH.
3. Values are typically available over long periods of time.
4. Access to the aggregation tables of the Process Historian is possible.
5. Data from both the PH database and the OS server can be displayed in one
report.
6. Specify the name of the ODBC data source, a description, and the SQL Server
of the Process Historian.
7. Click the "Next" button.
© Siemens AG 2019 All rights reserved
9. Set the checkbox "Change the default database to:" and select the database
"HistorianStorage".
11. Click the "Test Data Source" button to test the ODBC database connection.
Result:
The ODBC data source has been created.
NOTE • Using the IS Stored Procedures against the ODBC data source does not work.
• Only stored procedure calls with fixed parameters can be used.
• Only direct database queries against PH tables or PH views can be used.
• More complex database queries often do not work with the ODBC data source.
© Siemens AG 2019 All rights reserved
NOTE For more information on the PH database, see the article "Creating Report
Templates with Report Builder".
https://support.industry.siemens.com/cs/ww/en/view/64906050
NOTE When converting the time stamp to the local time of the OS server, rounding
errors occur in the millisecond range!
Result
In the following example, the last stored minute aggregate is returned. The UTC
timestamp is converted to the local OS server time.
Max Value:
Use HistorianStorage
SELECT TOP 1
convert(datetime,DATEADD(SECOND,DATEDIFF(SECOND,getutcdate(),GETDATE()),[TimeSta
mp_MAX])) as Local_Time_Calculated
,[TimeStamp_MAX] as UTC_Time_Recorded
,[Agg_MAX] as Max_Value_Last_Minute
FROM [HistorianStorage].[TLG].[VAggregateValue]
where TagUID = '8333E584-E13E-4F6B-84C9-F53B96D14DFE' and AggregateID = 1
order by TimeStamp desc
Min Value:
Use HistorianStorage
SELECT TOP 1
convert(datetime,DATEADD(SECOND,DATEDIFF(SECOND,getutcdate(),GETDATE()),[TimeSta
mp_MIN])) as Local_Time_Calculated
,[TimeStamp_MIN] as UTC_Time_Recorded
,[Agg_MIN] as Min_Value_Last_Minute
FROM [HistorianStorage].[TLG].[VAggregateValue]
where TagUID = '8333E584-E13E-4F6B-84C9-F53B96D14DFE' and AggregateID = 1
order by TimeStamp desc
Result:
In the following example, the last 7 tag aggregates are read. The UTC timestamp is
converted to the local OS server time.
use HistorianStorage
Select
convert(datetime,DATEADD(SECOND,DATEDIFF(SECOND,getutcdate(),GETDATE()),[TimeStamp_
MAX])) as Local_Time_Calculated
--,[TimeStamp_MAX] as Time_Max_UTC
,[Agg_MAX] as Max_Value
,convert(datetime,DATEADD(SECOND,DATEDIFF(SECOND,getutcdate(),GETDATE()),[TimeStamp
_MIN])) as Local_Time_Calculated
--,[TimeStamp_Min] as Time_Min_UTC
© Siemens AG 2019 All rights reserved
,[Agg_MIN] as Min_Value
FROM [HistorianStorage].[TLG].[VAggregateValue]
where TagUID = '8333E584-E13E-4F6B-84C9-F53B96D14DFE'
-and AggregateID = 3
and TimeStamp_max >= DATEADD(DD,-7,Sysutcdatetime()) and TimeStamp <=
Sysutcdatetime()
order by TimeStamp desc
Result
FROM [HistorianStorage].[ALG].[VMessage]
where TimeStamp >= DATEADD(hh,-1,Sysutcdatetime()) and TimeStamp <=
Sysutcdatetime()
and convert(nvarchar(max),MessageTexts) like '%MatCount%'
order by TimeStamp desc
Result
NOTE Messages can be displayed more comfortably with the WinCC Report function.
© Siemens AG 2019 All rights reserved
9. Insert a static text from the "Standard Object" palette into the report.
11. Insert an "ODBC Database Table" from the "Standard Object" palette into the
report.
12. Open the "Object Properties" of the "ODBC Database Tables" via the context
menu.
13. Select the "Database link" and click on the "Edit" button.
NOTE The SQL Query can be found in the chapter "Reading daily aggregates".
The TagUID must be determined on the Process Historian and adjusted
accordingly.
Result
The SQL query is executed and returns the result.
© Siemens AG 2019 All rights reserved
Result
6. Switch to the "Printer Setup" tab and configure your PDF printer.
© Siemens AG 2019 All rights reserved
Result
After you have performed a screen change on the OS Runtime, you can print the
report.
6 Report Example
© Siemens AG 2019 All rights reserved
7 Appendix
7.1 Service and support
Industry Online Support
Do you have any questions or need assistance?
Siemens Industry Online Support offers round the clock access to our entire
service and support know-how and portfolio.
The Industry Online Support is the central address for information about our
products, solutions and services.
Product information, manuals, downloads, FAQs, application examples and videos
– all information is accessible with just a few mouse clicks:
support.industry.siemens.com
Technical Support
The Technical Support of Siemens Industry provides you fast and competent
support regarding all technical queries with numerous tailor-made offers
– ranging from basic support to individual support contracts. Please send queries
to Technical Support via Web form:
www.siemens.com/industry/supportrequest
© Siemens AG 2019 All rights reserved
Service offer
Our range of services includes the following:
• Plant data services
• Spare parts services
• Repair services
• On-site and maintenance services
• Retrofitting and modernization services
• Service programs and contracts
You can find detailed information on our range of services in the service catalog
web page:
support.industry.siemens.com/cs/sc