Application example 03/2017 APF report templates based on data from the WinCC User Archive PCS 7, Information Server https://support.industry.siemens.com/cs/ww/en/view/64906050
Warranty and liability Warranty and liability Note The Application Examples are not binding and do not claim to be complete regarding the circuits shown, equipping and any eventuality. The Application Examples do not represent customer-specific solutions. They are only intended to provide support for typical applications. You are responsible for ensuring that the described products are used correctly. These Application Examples do not relieve you of the responsibility to use safe practices in application, installation, operation and maintenance. When using these Application Examples, you recognize that we cannot be made liable for any damage/claims beyond the liability clause described. We reserve the right to make changes to these Application Examples at any time without prior notice. If there are any deviations between the recommendations provided in these Application Examples and other Siemens publications e.g. Catalogs the contents of the other documents have priority. We do not accept any liability for the information contained in this document. Any claims against us based on whatever legal reason resulting from the use of the examples, information, programs, engineering and performance data etc., described in this Application Example shall be excluded. Such an exclusion shall not apply in the case of mandatory liability, e.g. under the German Product Liability Act ( Produkthaftungsgesetz ), in case of intent, gross negligence, or injury of life, body or health, guarantee for the quality of a product, fraudulent concealment of a deficiency or breach of a condition which goes to the root of the contract ( wesentliche Vertragspflichten ). The damages for a breach of a substantial contractual obligation are, however, limited to the foreseeable damage, typical for the type of contract, except in the event of intent or gross negligence or injury to life, body or health. The above provisions do not imply a change of the burden of proof to your detriment. Any form of duplication or distribution of these Application Examples or excerpts hereof is prohibited without the expressed consent of the Siemens AG. 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 only form one element of such a concept. Customers are responsible for preventing unauthorized access to their plants, systems, machines and networks. Systems, machines and components should be connected to the enterprise network or the Internet only where necessary, only to the extent needed and only with appropriate security measures (e.g. use of firewalls and network segmentation) in place. Additionally, Siemens guidance on appropriate security measures must be taken into account. For more information about industrial security, please visit http://www.siemens.com/industrialsecurity. Siemens products and solutions undergo continuous development to make them even more secure. Siemens strongly recommends applying product updates as soon as available and to always use the latest product versions. Using versions that are obsolete or are no longer supported can increase the risk of cyber threats. To stay informed about product updates, subscribe to the Siemens Industrial Security RSS Feed under http://www.siemens.com/industrialsecurity. Entry ID: 64906050, V1.0, 03/2017 2
Table of contents Table of contents Warranty and liability... 2 1 Introduction... 4 2 Creating a user-defined report... 5 2.1 Operating principle... 5 2.2 Example data... 6... 7 3.1 Creating connection to WinCC database... 7 3.2 Defining the data contents of the report... 9 3.3 Layout definition... 14 3.4 Uploading the report template... 20 3.5 Creating a report... 24 4 Appendix... 26 4.1 Service and Support... 26 4.2 Links and Literature... 27 4.3 Documentation of changes... 27 Entry ID: 64906050, V1.0, 03/2017 3
1 Introduction 1 Introduction Advanced Process Functions Reports with APF The SIMATIC PCS 7 Advanced Process Functions (APF) automates simple batch processes for small and medium-sized automation systems with simple material processing. These are mainly dosing, mixing or stirring systems. The modules for material management, parameter management, task management, and archive management support automation of the production process from the raw materials intake to release for filling and packing. The PCS 7 add-on APF does not contain an independent function for generating reports from the WinCC User Archive used. The generation of reports with APF is carried out via the report templates of the information server, which uses the WinCC User Archive as its data base. Core contents of the Application Example The following documentation describes how the SIMATIC Information Server can be used to create complex and detailed reports and thus display the data generated by APF in a meaningful and appealing form. Validity SIMATIC Information Server 2014 SIMATIC PCS 7 V8.2 Entry ID: 64906050, V1.0, 03/2017 4
2 Creating a user-defined report 2 Creating a user-defined report 2.1 Operating principle These five steps must be followed in order to create a user-defined report: 1. Create a (redundant) connection between the information server and the WinCC database (Section 3.1). 2. Create a new report template in the MS Report Builder based on the default template ISBase.rdl and define the data content / SQL queries (Section 3.2). 3. Define the report layout in the MS Report Builder. (Section 3.3). 4. Upload the report template to the information server (Section 3.4). 5. Create a report using the Information Server client (Section 3.5). Database query prerequisites To create a consistent report, the following constraints must be observed: 1. The name of the WinCC Runtime database must be called up dynamically during the database query, since the name of the WinCC Runtime database can change, for example, by downloading a project completely or by archiving / retrieving a project in SIMATIC Manager. 2. Implement a handling for server redundancy if the default master is not available or cannot be started. Entry ID: 64906050, V1.0, 03/2017 5
2 Creating a user-defined report 2.2 Example data The following example shows how a pie chart can be created from the data of two WinCC user archives used by APF. The first WinCC User Archive contains the material management data (FB_MATERIAL_001). The second WinCC User Archive contains the data for production tracking (FB_ARCHIVING_001). Entry ID: 64906050, V1.0, 03/2017 6
3.1 Creating connection to WinCC database In this example, a redundant OS server pair (SV80A and SV80B) is connected to the information server. 1. Start the Information Server client. 2. Go to the Configuration" view and click on "Reporting". 3. Under "Connect projects", fill in the appropriate fields and then click on the "Select projects button: Server name or IP address: SV80A (Default Master/ Single OS Server or OS Single Station) Type: WinCC- / PCS 7 OS SQL instance: wincc Entry ID: 64906050, V1.0, 03/2017 7
4. Enter a project name, activate the options box and click on the "OK" button. Result An information server connection to the redundant WinCC OS server pair has been successfully created. Information Server Client (left) The project will be created under the given name SV80A. The name "SV80A" is used for the "project" parameter when the report is created. SQL Management Studio (right) In the SQL server instance of the information server, the two linked servers SV80A\wincc and SV80B\wincc are created automatically under "Server Objects -> Linked Servers". Within the report template, these are referenced as SQL server instances for the data query. Entry ID: 64906050, V1.0, 03/2017 8
3.2 Defining the data contents of the report This example refers to the two example WinCC User Archives from Section 2.2 "FB_MATERIAL_001" and "FB_ARCHIVING_001" of the APF demo project. 1. Copy the template "ISBase.rdl" from the corresponding folder and open it. (C:\Program Files (x86)\siemens\informationserver\rdl\isbase.rdl) 2. Open the report properties via right-clicking> Report Properties... " Entry ID: 64906050, V1.0, 03/2017 9
3. Click on References and delete the complement:,version=7.3.0.0, Culture=neutral, PublicKeyToken=10e6533682f60eab. Confirm by clicking on the "OK button. 4. To access the data in the WinCC User Archive, right-click Add Dataset... " Note The Text query offers the most flexibility. Entry ID: 64906050, V1.0, 03/2017 10
5. The following query includes the determination of the database name as well as the overlapping of the server redundancy and connects NAME and TYPE from "FB_MATERIAL_001" to PV (= process value production quantity ) from "FB_ARCHIVING_001" (archiving group type "BATCH-related"). Query for redundancy cover and WinCC Runtime database name finding DECLARE @prefix AS SYSNAME, @retval int SET @prefix = 'SV80A\WINCC' SET @retval = 0 BEGIN TRY EXEC @retval = sys.sp_testlinkedserver @prefix END TRY BEGIN CATCH SET @retval = sign(@@error) END CATCH IF @retval = 0 SELECT @prefix = '[SV80A\WINCC].' + name + '.dbo.' FROM [SV80A\WINCC].master.sys.databases WHERE name LIKE 'CC_%R' IF @retval <> 0 OR @prefix = 'SV80A\WINCC' SELECT @prefix = '[SV80B\WINCC].' + name + '.dbo.' FROM [SV80B\WINCC].master.sys.databases WHERE name LIKE 'CC_%R' Entry ID: 64906050, V1.0, 03/2017 11
Query without redundancy cover: DECLARE @prefix AS SYSNAME SELECT @prefix = '[SV80A\WINCC].' + name + '.dbo.' FROM [SV80A\WINCC].master.sys.databases WHERE name LIKE 'CC_%R' Query for the desired data in the report EXECUTE ( ) SELECT UA#FB_MATERIAL_001.NAME AS ProductName,UA#FB_ARCHIVING_001.PV AS Quantity FROM ' + @prefix + 'UA#FB_ARCHIVING_001 INNER JOIN ' + @prefix + 'UA#FB_MATERIAL_001 ON UA#FB_MATERIAL_001.REC_ID = UA#FB_ARCHIVING_001.MAT_ID WHERE UA#FB_MATERIAL_001.TYPE = 2' Result A database query and its content were created. Entry ID: 64906050, V1.0, 03/2017 12
Testing the database query Before the report is implemented, the query should be pre-tested in the SQL Management Studio (the aggregate (SUM... GROUP BY) explicitly added in the following query is implicitly executed by the report generator) Query for the SQL Management Studio as plain text: -- How to access WinCC user archives on redundant OS servers -- use cases covered by this approach: -- while server B is in master mode: -- - server A is switched off -- - WinCC project has not been opened on server A -- - server A is in stand-by mode (data synchronized from server B) -- use cases NOT covered by this approach: -- - WinCC project has been opened on server A, but not started yet: old outdated data will be read out from server A -- Adaption to other projects: server A name to be adapted 4 times, server B name to be adapted 2 times (do not add or remove any brackets) DECLARE @prefix AS SYSNAME, @retval int -- define server A database instance name as shown in Linked Servers list (without brackets, to be adapted 1 time) SET @prefix = 'SV80A\WINCC' SET @retval = 0 -- check whether server A is available BEGIN TRY EXEC @retval = sys.sp_testlinkedserver @prefix END TRY BEGIN CATCH SET @retval = sign(@@error) END CATCH -- if server A is available: IF @retval = 0 Entry ID: 64906050, V1.0, 03/2017 13
-- define prefix for server A database instance name (including brackets, to be adapted 2 times!) SELECT @prefix = '[SV80A\WINCC].' + name + '.dbo.' FROM [SV80A\WINCC].master.sys.databases WHERE name LIKE 'CC_%R' -- if server A is not available -- or CC_%R database has not been found in server A database instance (without brackets, to be adapted 1 time) in case of WinCC project closed: IF @retval <> 0 OR @prefix = 'SV80A\WINCC' -- define prefix for server B database instance name (including brackets, to be adapted 2 times!) SELECT @prefix = '[SV80B\WINCC].' + name + '.dbo.' FROM [SV80B\WINCC].master.sys.databases WHERE name LIKE 'CC_%R' -- for check in Messages window (e.g. "@prefix = [SV80A\WINCC].CC_OSS1_16_12_06_08_27_29R.dbo.") PRINT '@prefix = ' + @prefix -- define statement, add prefix to each table name EXECUTE ( SELECT UA#FB_MATERIAL_001.NAME AS ProductName,SUM(UA#FB_ARCHIVING_001.PV) AS Quantity FROM ' + @prefix + 'UA#FB_ARCHIVING_001 INNER JOIN ' + @prefix + 'UA#FB_MATERIAL_001 ON UA#FB_MATERIAL_001.REC_ID = UA#FB_ARCHIVING_001.MAT_ID ) WHERE UA#FB_MATERIAL_001.TYPE = 2 GROUP BY UA#FB_MATERIAL_001.NAME' 3.3 Layout definition Use the Chart Wizard to display the data from "DataSet1" as a pie chart. 1. Open the Chart Wizard by selecting "Chart> Chart Wizard...". Entry ID: 64906050, V1.0, 03/2017 14
2. Select the desired data set and click on the "Next" button. 3. Select "Pie Chart" as chart type and then click on the "Next>" button. Entry ID: 64906050, V1.0, 03/2017 15
4. Select the "ProductName" field as the category and the "Quantity" field for the sum totals, then click on the "Next>" button. 5. Select the desired display style and then click on the Finish>>" button. Entry ID: 64906050, V1.0, 03/2017 16
6. To display the values in the pie chart, open the context menu by clicking with the right mouse button on the diagram "Add data labels" in the pie chart. 7. Click on the "Run button. Entry ID: 64906050, V1.0, 03/2017 17
8. Select the project. To create a report, click on the "View Report" button. Result Note The name of the project corresponds to the name of the connection between the WinCC Runtime project and the information server in Section 3.1. A production report has been created with the desired type of data display. Entry ID: 64906050, V1.0, 03/2017 18
Changes to the database query allow you to display other information, such as, for instance, raw material consumption. Entry ID: 64906050, V1.0, 03/2017 19
3.4 Uploading the report template Name the report template as it is to appear in the information server client. 1. Open the report properties via right-click> Report Properties. 2. Go to "Default Values" and click on the "Function" button. Entry ID: 64906050, V1.0, 03/2017 20
3. Replace the expression "ISBase" with a label of your choice (for example, "APF Production Report V1.1") and click on the "OK" button. 4. Save the report as an RDL file. Entry ID: 64906050, V1.0, 03/2017 21
5. Open the Information Server, change to Administration and click on Reporting. 6. Make a new folder under Templates. 7. Click on the created folder and click on the "Upload" button and "Select files.... Entry ID: 64906050, V1.0, 03/2017 22
8. Select the report you want to create and click on the Open button. Result The Report template has been successfully uploaded to the Information Server. Entry ID: 64906050, V1.0, 03/2017 23
3.5 Creating a report 1. Click on "Create report in the Information Server. 2. Select your project. Entry ID: 64906050, V1.0, 03/2017 24
3. Click on the "Show preview button. To create a report, click on the Create Report" button. Result A production report has been generated successfully. Entry ID: 64906050, V1.0, 03/2017 25
4 Appendix 4 Appendix 4.1 Service and Support Industry Online Support Technical 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 and application examples all information is accessible with just a few mouse clicks at: https://support.industry.siemens.com/. 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.en/industry/supportrequest. Service offer Our range of services includes, inter alia, the following: Product trainings 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: https://support.industry.siemens.com/cs/sc Industry Online Support app You will receive optimum support wherever you are with the "Siemens Industry Online Support" app. The app is available for Apple ios, Android and Windows Phone: https://support.industry.siemens.com/cs/ww/en/sc/2067 Entry ID: 64906050, V1.0, 03/2017 26
4 Appendix 4.2 Links and Literature Table 4-1 No. \1\ Siemens Industry Online Support https://support.industry.siemens.com Topic \2\ https://support.industry.siemens.com/cs/ww/en/view/64906050 \3\ 4.3 Documentation of changes Table 4-2 Version Date Change V1.0 03/2017 First version Entry ID: 64906050, V1.0, 03/2017 27