You are on page 1of 106

Instructions Manual

PLC Reports 2014


Edition 11/2014

1.

Safety instructions

This manual contains instructions you need to follow for your personal safety and to prevent damage
to property. Instructions for your personal safety are highlighted with a red warning icon. Notes on
possible damages show up with a yellow alert symbol. Depending on the danger level, the warnings
are shown as follows:

1.1.

Warning
Warning! means that death or serious injury can occur if the proper precautions are not taken.

1.2.

Caution

Caution! means that a minor to moderate injury or damage to property can occur if the proper
precautions are not taken.

1.3.

Note

Note! indicates that an unintended result or situation can occur if the corresponding
information is not heeded. If more than one degree of danger is present, the warning notice
representing the highest degree of danger will be used. If the warning note warns about personal
injury, damage to property may be included in the same warning note in addition.

1.4.

Qualified Personnel

PLC Reports as well as the associated system may only be set up and operated in conjunction with
this documentation. Commissioning and operation must only be performed by qualified personnel.
Qualified personnel in the sense of the safety notes in this documentation are persons who are
authorized to start up, identify and document machines and systems in accordance with the
standards of safety technology.

1.5.

Intended Use

Consider the following:


Warning!
PLC Reports may only be used for the purposes intended in the technical description. The proper
and safe operation of the product requires careful configuration, testing, commissioning, operation
and maintenance.

1.6.

Brands

All names identified with the sign are registered trademarks of SIS Industrial Software GmbH. Other
product names used in this publication may be trademarks whose use may infringe upon the rights of
the owner.

1.7.

Disclaimer

We have checked the contents of this document to ensure consistency with the software.
Nevertheless, deviations to the described software cannot be precluded entirely. The information in
this manual is reviewed regularly. Necessary corrections will be included in subsequent editions.

2.
1.

Table of Contents
Safety instructions ......................................................................................................................2

1.1.

Warning ..............................................................................................................................2

1.2.

Caution................................................................................................................................2

1.3.

Note ....................................................................................................................................2

1.4.

Qualified Personnel .............................................................................................................2

1.5.

Intended Use .......................................................................................................................3

1.6.

Brands .................................................................................................................................3

1.7.

Disclaimer............................................................................................................................3

2.

Table of Contents ........................................................................................................................4

3.

General ..................................................................................................................................... 16

4.

Archive Array Variable............................................................................................................... 17

5.

4.1.

Description ........................................................................................................................ 17

4.2.

Parameters ........................................................................................................................ 18

4.2.1.

Parameter 1: Index of the Variable to Read ................................................................ 18

4.2.2.

Parameter 2: Archive Name ....................................................................................... 18

4.2.3.

Parameter 3: Index of the Time Stamp Variable ......................................................... 18

4.2.4.

Parameter 4: Cycle ..................................................................................................... 18

4.2.5.

Parameter 5: Mode .................................................................................................... 18

4.3.

Sample Application ............................................................................................................ 20

4.4.

Workflow of the Instruction ............................................................................................... 20

4.5.

Possible Errors ................................................................................................................... 20

Archive Batch Index................................................................................................................... 22


5.1.

Description ........................................................................................................................ 22

5.2.

Parameters ........................................................................................................................ 22

5.2.1.

Parameter 1: Index of the Batch ID Variable to Read .................................................. 22

5.2.2.

Parameter 2: Archive Name ....................................................................................... 22

5.2.3.

Parameter 3: Batch Inactive Value ............................................................................. 22

5.2.4.

Parameter 4: Timestamp Mode or Index of the Batch Begin Timestamp Variable ....... 22

5.2.5.

Parameter 5: Index of the Batch End Timestamp Variable .......................................... 22

5.3.

Sample Application ............................................................................................................ 23

5.4.

Workflow of the Instruction ............................................................................................... 23


4

5.5.
6.

7.

8.

Possible Errors ................................................................................................................... 23

Archive Batch Index End ............................................................................................................ 25


6.1.

Description ........................................................................................................................ 25

6.2.

Parameters ........................................................................................................................ 25

6.2.1.

Parameter 1: Index of the Batch ID Variable to Read .................................................. 25

6.2.2.

Parameter 2: Archive Name ....................................................................................... 25

6.2.3.

Parameter 3: Batch Inactive Value ............................................................................. 25

6.2.4.

Parameter 4: Timestamp Mode or Index of the Batch End Timestamp Variable.......... 25

6.3.

Sample Application ............................................................................................................ 26

6.4.

Workflow of the Instruction ............................................................................................... 26

6.5.

Possible Errors ................................................................................................................... 26

Archive Variable ........................................................................................................................ 28


7.1.

Description ........................................................................................................................ 28

7.2.

Parameters ........................................................................................................................ 28

7.2.1.

Parameter 1: Index of the Variable to Read ................................................................ 28

7.2.2.

Parameter 2: Archive Name ....................................................................................... 28

7.2.3.

Parameter 3: Mode .................................................................................................... 28

7.3.

Sample Application ............................................................................................................ 30

7.4.

Workflow of the Instruction ............................................................................................... 30

7.5.

Possible Errors ................................................................................................................... 31

Check Negative Edge ................................................................................................................. 32


8.1.

Description ........................................................................................................................ 32

8.2.

Parameters ........................................................................................................................ 32

8.2.1.

9.

Parameter 1: Archive Name ....................................................................................... 32

8.3.

Sample Application ............................................................................................................ 32

8.4.

Workflow of the Instruction ............................................................................................... 32

8.5.

Possible Errors ................................................................................................................... 32

Check New Period ..................................................................................................................... 33


9.1.

Description ........................................................................................................................ 33

9.2.

Parameters ........................................................................................................................ 33

9.2.1.

Parameter 1: Time Range ........................................................................................... 33

9.3.

Sample Application ............................................................................................................ 33

9.4.

Workflow of the Instruction ............................................................................................... 33


5

9.5.
10.

Possible Errors ................................................................................................................... 33


Check Positive Edge ............................................................................................................... 34

10.1.

Description .................................................................................................................... 34

10.2.

Parameters .................................................................................................................... 34

10.2.1.

Parameter 1: Archive Name ....................................................................................... 34

10.3.

Sample Application ........................................................................................................ 34

10.4.

Workflow of the Instruction ........................................................................................... 34

10.5.

Possible Errors ............................................................................................................... 34

11.

Check Value Change .............................................................................................................. 35

11.1.

Description .................................................................................................................... 35

11.2.

Parameters .................................................................................................................... 35

11.2.1.

Parameter 1: Archive Name ....................................................................................... 35

11.3.

Sample Application ........................................................................................................ 35

11.4.

Workflow of the Instruction ........................................................................................... 35

11.5.

Possible Errors ............................................................................................................... 35

12.

Check Variable Value Change ................................................................................................ 36

12.1.

Description .................................................................................................................... 36

12.2.

Parameters .................................................................................................................... 36

12.2.1.

Parameter 1: Variable Index ....................................................................................... 36

12.2.2.

Parameter 2: Dead Band ............................................................................................ 36

12.2.3.

Parameter 3: Inactive Value ....................................................................................... 36

12.2.4.

Parameter 4: Value Following an Inactive Value is a Change (Yes/No) ........................ 36

12.3.

Sample Application ........................................................................................................ 36

12.4.

Workflow of the Instruction ........................................................................................... 37

12.5.

Possible Errors ............................................................................................................... 37

13.

Check Working Copy ............................................................................................................. 38

13.1.

Description .................................................................................................................... 38

13.2.

Parameters .................................................................................................................... 38

13.2.1.

Parameter 1: Maximum Age ...................................................................................... 38

13.3.

Sample Application ........................................................................................................ 39

13.4.

Workflow of the Instruction ........................................................................................... 39

13.5.

Possible Errors ............................................................................................................... 39

14.

Clean Report ......................................................................................................................... 40


6

14.1.

Description .................................................................................................................... 40

14.2.

Parameters .................................................................................................................... 40

14.3.

Sample Application ........................................................................................................ 40

14.4.

Workflow of the Instruction ........................................................................................... 40

14.5.

Possible Errors ............................................................................................................... 41

15.

Close Report File ................................................................................................................... 42

15.1.

Description .................................................................................................................... 42

15.2.

Parameters .................................................................................................................... 42

15.3.

Sample Application ........................................................................................................ 42

15.4.

Workflow of the Instruction ........................................................................................... 42

15.5.

Possible Errors ............................................................................................................... 42

16.

Compare Two Variables......................................................................................................... 43

16.1.

Description .................................................................................................................... 43

16.2.

Parameters .................................................................................................................... 43

16.2.1.

Parameter 1: Comparison Expression ......................................................................... 43

16.3.

Sample Application ........................................................................................................ 43

16.4.

Workflow of the Instruction ........................................................................................... 43

16.5.

Possible Errors ............................................................................................................... 44

17.

Compare Variable.................................................................................................................. 45

17.1.

Description .................................................................................................................... 45

17.2.

Parameters .................................................................................................................... 45

17.2.1.

Parameter 1: Comparison Expression ......................................................................... 45

17.3.

Sample Application ........................................................................................................ 45

17.4.

Workflow of the Instruction ........................................................................................... 45

17.5.

Possible Errors ............................................................................................................... 46

18.

Copy Variable ........................................................................................................................ 47

18.1.

Description .................................................................................................................... 47

18.2.

Parameters .................................................................................................................... 47

18.2.1.

Parameter 1: Source Variable Index ........................................................................... 47

18.2.2.

Parameter 2: Destination Variable Index .................................................................... 47

18.3.

Sample Application ........................................................................................................ 47

18.4.

Workflow of the Instruction ........................................................................................... 47

18.5.

Possible Errors ............................................................................................................... 47


7

19.

Create New Report File ......................................................................................................... 48

19.1.

Description .................................................................................................................... 48

19.1.1.

Output Directory ........................................................................................................ 48

19.1.2.

Final Output Directory ............................................................................................... 48

19.2.

Parameters .................................................................................................................... 48

19.3.

Sample Application ........................................................................................................ 48

19.4.

Workflow of the Instruction ........................................................................................... 48

19.5.

Possible Errors ............................................................................................................... 49

20.

Disable Trigger Warning ........................................................................................................ 50

20.1.

Description .................................................................................................................... 50

20.2.

Parameters .................................................................................................................... 50

20.3.

Sample Application ........................................................................................................ 50

20.4.

Workflow of the Instruction ........................................................................................... 50

21.

Delete Report File.................................................................................................................. 51

21.1.

Description .................................................................................................................... 51

21.2.

Parameters .................................................................................................................... 51

21.3.

Sample Application ........................................................................................................ 51

21.4.

Workflow of the Instruction ........................................................................................... 51

21.5.

Possible Errors ............................................................................................................... 51

22.

Exit ........................................................................................................................................ 52

22.1.

Description .................................................................................................................... 52

22.2.

Parameters .................................................................................................................... 52

22.3.

Sample Application ........................................................................................................ 52

22.4.

Workflow of the Instruction ........................................................................................... 52

22.5.

Possible Errors ............................................................................................................... 52

23.

Get Change Data ................................................................................................................... 53

23.1.

Description .................................................................................................................... 53

23.2.

Parameters .................................................................................................................... 53

23.2.1.

Parameter 1: Archive Name ....................................................................................... 53

23.3.

Sample Application ........................................................................................................ 53

23.4.

Workflow of the Instruction ........................................................................................... 53

23.5.

Possible Errors ............................................................................................................... 54

24.

Go To .................................................................................................................................... 55
8

24.1.

Description .................................................................................................................... 55

24.2.

Parameters .................................................................................................................... 55

24.2.1.

Parameter 1: Instruction Index ................................................................................... 55

24.3.

Sample Application ........................................................................................................ 55

24.4.

Workflow of the Instruction ........................................................................................... 55

24.5.

Possible Errors ............................................................................................................... 55

25.

Go To If No ............................................................................................................................ 56

25.1.

Description .................................................................................................................... 56

25.2.

Parameters .................................................................................................................... 56

25.2.1.

Parameter 1: Instruction Index ................................................................................... 56

25.3.

Sample Application ........................................................................................................ 56

25.4.

Workflow of the Instruction ........................................................................................... 56

25.5.

Possible Errors ............................................................................................................... 56

26.

Go To If Yes ........................................................................................................................... 57

26.1.

Description .................................................................................................................... 57

26.2.

Parameters .................................................................................................................... 57

26.2.1.

Parameter 1: Instruction Index ................................................................................... 57

26.3.

Sample Application ........................................................................................................ 57

26.4.

Workflow of the Instruction ........................................................................................... 57

26.5.

Possible Errors ............................................................................................................... 57

27.

Open Report File ................................................................................................................... 58

27.1.

Description .................................................................................................................... 58

27.2.

Parameters .................................................................................................................... 58

27.3.

Sample Application ........................................................................................................ 58

27.4.

Workflow of the Instruction ........................................................................................... 58

27.5.

Possible Errors ............................................................................................................... 58

28.

Print Report........................................................................................................................... 59

28.1.

Description .................................................................................................................... 59

28.2.

Parameters .................................................................................................................... 59

28.2.1.

Parameter 1: Worksheet ............................................................................................ 59

28.2.2.

Parameter 2: Printer Name ........................................................................................ 59

28.3.

Sample Application ........................................................................................................ 59

28.4.

Workflow of the Instruction ........................................................................................... 60


9

28.5.
29.

Possible Errors ............................................................................................................... 60

Publish Range ........................................................................................................................ 61

29.1.

Description .................................................................................................................... 61

29.2.

Parameters .................................................................................................................... 61

29.2.1.

Parameter 1: Worksheet Name .................................................................................. 61

29.2.2.

Parameter 2: Start Cell ............................................................................................... 61

29.2.3.

Parameter 3: End Cell................................................................................................. 61

29.2.4.

Parameter 4: Path and Filename ................................................................................ 61

29.3.

Sample Application ........................................................................................................ 61

29.4.

Workflow of the Instruction ........................................................................................... 61

29.5.

Possible Errors ............................................................................................................... 62

30.

Read Archived Variable ......................................................................................................... 63

30.1.

Description .................................................................................................................... 63

30.2.

Parameters .................................................................................................................... 63

30.2.1.

Parameter 1: Archive Name ....................................................................................... 63

30.2.2.

Parameter 2: Start Time or Special Time Range .......................................................... 63

30.2.3.

Parameter 3: End Time or Insert Cells ........................................................................ 64

30.2.4.

Parameter 4: Insert Rows ........................................................................................... 64

30.3.

Sample Application ........................................................................................................ 64

30.4.

Workflow of the Instruction ........................................................................................... 64

30.5.

Possible Errors ............................................................................................................... 65

31.

Read Batch Index Data .......................................................................................................... 66

31.1.

Description .................................................................................................................... 66

31.2.

Parameters .................................................................................................................... 66

31.2.1.

Parameter 1: Archive Name ....................................................................................... 66

31.2.2.

Parameter 2: Index of a Variable Containing the Requested Batch ID ......................... 66

31.2.3.

Parameter 3: Error Message if the Batch ID Was Not Found in the Archive................. 66

31.3.

Sample Application ........................................................................................................ 66

31.4.

Workflow of the Instruction ........................................................................................... 66

31.5.

Possible Errors ............................................................................................................... 67

32.

Read Indexed Variable........................................................................................................... 68

32.1.

Description .................................................................................................................... 68

32.2.

Parameters .................................................................................................................... 68
10

32.2.1.

Parameter 1: Index of the Index Variable ................................................................... 68

32.3.

Sample Application ........................................................................................................ 68

32.4.

Workflow of the Instruction ........................................................................................... 68

32.5.

Possible Errors ............................................................................................................... 69

33.

Read SQL Access .................................................................................................................... 70

33.1.

Description .................................................................................................................... 70

33.2.

Data Provider................................................................................................................. 70

33.3.

Parameters .................................................................................................................... 71

33.3.1.

Parameter 1: Variable Range...................................................................................... 71

33.3.2.

Parameter 2: Columns of the database table.............................................................. 71

33.3.3.

Parameter 3: Insert Rows ........................................................................................... 71

33.3.4.

Parameter 4: Connection String ................................................................................. 71

33.3.5.

Parameter 5: SQL Query............................................................................................. 72

33.4.

Sample Application ........................................................................................................ 72

33.5.

Workflow of the Instruction ........................................................................................... 72

33.6.

Possible Errors ............................................................................................................... 73

34.

Read SQL CSV ........................................................................................................................ 75

34.1.

Description .................................................................................................................... 75

34.2.

Data Provider................................................................................................................. 75

34.3.

Schema.ini File ............................................................................................................... 75

34.4.

Parameters .................................................................................................................... 76

34.4.1.

Parameter 1: Variable Range...................................................................................... 76

34.4.2.

Parameter 2: Columns of the database table.............................................................. 76

34.4.3.

Parameter 3: Insert Rows ........................................................................................... 76

34.4.4.

Parameter 4: Connection String ................................................................................. 76

34.4.5.

Parameter 5: SQL Query............................................................................................. 77

34.5.

Sample Application ........................................................................................................ 77

34.6.

Workflow of the Instruction ........................................................................................... 77

34.7.

Possible Errors ............................................................................................................... 78

35.

Read SQL Server .................................................................................................................... 79

35.1.

Description .................................................................................................................... 79

35.2.

Parameters .................................................................................................................... 79

35.2.1.

Parameter 1: Variable Range...................................................................................... 79


11

35.2.2.

Parameter 2: Columns of the database table.............................................................. 79

35.2.3.

Parameter 3: Insert Rows ........................................................................................... 80

35.2.4.

Parameter 4: Connection String ................................................................................. 80

35.2.5.

Parameter 5: SQL Query ............................................................................................. 80

35.3.

Sample Application ........................................................................................................ 80

35.4.

Workflow of the Instruction ........................................................................................... 81

35.5.

Possible Errors ............................................................................................................... 82

36.

Read Variable ........................................................................................................................ 83

36.1.

Description .................................................................................................................... 83

36.2.

Parameters .................................................................................................................... 83

36.2.1.

Parameter 1: Index of the Variable............................................................................. 83

36.2.2.

Parameter 2: Insert Rows ........................................................................................... 83

36.3.

Sample Application ........................................................................................................ 83

36.4.

Workflow of the Instruction ........................................................................................... 83

36.5.

Possible Errors ............................................................................................................... 84

37.

Read Variable from Cell ......................................................................................................... 85

37.1.

Description .................................................................................................................... 85

37.2.

Parameters .................................................................................................................... 85

37.2.1.

Parameter 1: Index of the Variable ............................................................................. 85

37.3.

Sample Application ........................................................................................................ 85

37.4.

Workflow of the Instruction ........................................................................................... 85

37.5.

Possible Errors ............................................................................................................... 85

38.

Read Variable Range ............................................................................................................. 86

38.1.

Description .................................................................................................................... 86

38.2.

Parameters .................................................................................................................... 86

38.2.1.

Parameter 1: Index Range .......................................................................................... 86

38.3.

Sample Application ........................................................................................................ 86

38.4.

Workflow of the Instruction ........................................................................................... 86

38.5.

Possible Errors ............................................................................................................... 86

39.

Run Macro ............................................................................................................................ 87

39.1.

Description .................................................................................................................... 87

39.2.

Parameters .................................................................................................................... 87

39.2.1.

Parameter 1: Macro Name ......................................................................................... 87


12

39.3.

Sample Application ........................................................................................................ 87

39.4.

Workflow of the Instruction ........................................................................................... 88

39.5.

Possible Errors ............................................................................................................... 88

40.

Save Final Report File ............................................................................................................ 89

40.1.

Description .................................................................................................................... 89

40.2.

Parameters .................................................................................................................... 89

40.2.1.

Parameter 1: User Defined File Name ........................................................................ 89

40.3.

Sample Application ........................................................................................................ 89

40.4.

Workflow of the Instruction ........................................................................................... 89

40.5.

Possible Errors ............................................................................................................... 90

41.

Save Report as PDF ................................................................................................................ 91

41.1.

Description .................................................................................................................... 91

41.2.

Parameters .................................................................................................................... 91

41.2.1.

Parameter 1: Worksheet ............................................................................................ 91

41.2.2.

Parameter 2: User Defined File Name ........................................................................ 91

41.3.

Sample Application ........................................................................................................ 91

41.4.

Workflow of the Instruction ........................................................................................... 92

41.5.

Possible Errors ............................................................................................................... 92

42.

Save Report File..................................................................................................................... 93

42.1.

Description .................................................................................................................... 93

42.2.

Parameters .................................................................................................................... 93

42.3.

Sample Application ........................................................................................................ 93

42.4.

Workflow of the Instruction ........................................................................................... 93

42.5.

Possible Errors ............................................................................................................... 93

43.

Send Report As Email ............................................................................................................ 94

43.1.

Description .................................................................................................................... 94

43.2.

Parameters .................................................................................................................... 94

43.2.1.

Parameter 1: Sender Email Account ........................................................................... 94

43.2.2.

Parameter 2: From ..................................................................................................... 94

43.2.3.

Parameter 3: Recipient Email Address ........................................................................ 94

43.2.4.

Parameter 4: Subject ................................................................................................. 94

43.2.5.

Parameter 5: Message Text ........................................................................................ 94

43.2.6.

Parameter 6: Mail Server ........................................................................................... 94


13

43.2.7.

Parameter 7: Port ...................................................................................................... 94

43.2.8.

Parameter 8: Password .............................................................................................. 94

43.2.9.

Parameter 9: SSL ........................................................................................................ 94

43.2.10.

Parameter 10: Timeout .......................................................................................... 95

43.3.

Sample Application ........................................................................................................ 95

43.4.

Workflow of the Instruction ........................................................................................... 95

43.5.

Possible Errors ............................................................................................................... 95

44.

User Input ............................................................................................................................. 96

44.1.

Description .................................................................................................................... 96

44.2.

Parameters .................................................................................................................... 96

44.2.1.

Parameter 1: Time Range or Batch ID ......................................................................... 96

44.3.

Sample Application ........................................................................................................ 96

44.4.

Workflow of the Instruction ........................................................................................... 96

44.5.

Possible Errors ............................................................................................................... 96

45.

Write SQL Access ................................................................................................................... 97

45.1.

Description .................................................................................................................... 97

45.2.

Data Provider................................................................................................................. 97

45.3.

Parameters .................................................................................................................... 97

45.3.1.

Parameter 1: Connection String ................................................................................. 97

45.3.2.

Parameter 2: SQL Command ...................................................................................... 98

45.4.

Sample Application ........................................................................................................ 98

45.5.

Workflow of the Instruction ........................................................................................... 98

45.6.

Possible Errors ............................................................................................................... 99

46.

Write CSV ............................................................................................................................ 100

46.1.

Description .................................................................................................................. 100

46.2.

Parameters .................................................................................................................. 100

46.2.1.

Parameter 1: Name and Path of the CSV File ............................................................ 100

46.2.2.

Parameter 2: Column Separator ............................................................................... 100

46.2.3.

Parameter 3-n: List of Variables ............................................................................... 100

46.3.

Sample Application ...................................................................................................... 100

46.4.

Workflow of the Instruction ......................................................................................... 100

46.5.

Possible Errors ............................................................................................................. 101

47.

Write SQL Server ................................................................................................................. 102


14

47.1.

Description .................................................................................................................. 102

47.2.

Parameters .................................................................................................................. 102

47.2.1.

Parameter 1: Connection String ............................................................................... 102

47.2.2.

Parameter 2: SQL Command .................................................................................... 102

47.3.

Sample Application ...................................................................................................... 103

47.4.

Workflow of the Instruction ......................................................................................... 103

47.5.

Possible Errors ............................................................................................................. 104

48.

Write Variable ..................................................................................................................... 105

48.1.

Description .................................................................................................................. 105

48.2.

Parameters .................................................................................................................. 105

48.2.1.

Parameter 1: Index of the Variable ........................................................................... 105

48.3.

Sample Application ...................................................................................................... 105

48.4.

Workflow of the Instruction ......................................................................................... 105

48.5.

Possible Errors ............................................................................................................. 106

15

3.

General

This document describes instructions provided by PLC Reports to be used to create reports.
Reports are created by sequential execution of instructions defined in the worksheet Instructions
of the corresponding report template. Depending on the instruction type, different parameters can
be passed to the command.
The following chapters give detailed descriptions of the functionality, the syntax as well as the
possible parameters of each instruction. Furthermore it describes errors and its possible sources.

16

4.

Archive Array Variable

4.1.

Description

The instruction Archive Array Variable is used to archives values with fast acquisition cycles, e.g.
10ms. Because such values cannot be read reliably in real-time due to Ethernet limitations, often a
PLC memory buffer is used to store the values temporarily until they are read by the data acquisition
system. The instruction Archive Array Variable reads such buffer arrays of values from the PLC and
moves them into a data archive. The time stamp of the buffers first value is read by means of a
second variable. The timestamps of the following values are calculated on basis of an adjustable
cycle.
Note!
To display timestamps in the desired format, the destination Excel cells must be formatted correctly.
By default, Excel does not provide a format for displaying timestamps showing full details about both
date and time in the same cell. To get a fully-detailed display, a custom format needs to be used.
Right click the cell to format and select Format Cells Custom. Enter the desired format into the
field Type.
Example: mm/dd/yyyy h:mm:ss AM/PM will be displayed as 12/22/2007 2:20:04 PM

17

4.2.

Parameters

The command requires at least 4 parameters: The index of the variable to read, the name of the
archive to write the value into, the index of the timestamp variable and the cycle. The archiving
mode can be passed optionally.
4.2.1. Parameter 1: Index of the Variable to Read
Valid values are indexes of defined variables. This parameter is always required.
4.2.2. Parameter 2: Archive Name
Valid values are names of defined archives. This parameter is always required.
4.2.3. Parameter 3: Index of the Time Stamp Variable
Valid values are indexes of defined variables. This parameter is always required.
4.2.4. Parameter 4: Cycle
Valid values are timespans in milliseconds, seconds, minutes or hours:
- n Msec
- n Millisec
- 1 Millisecond
- n Milliseconds
- n Sec
- 1 Second
- n Seconds
- 1 Minute
- n Minutes
- 1 Hour
- n Hours
This parameter is always required.
4.2.5. Parameter 5: Mode
Several calculation functions can be performed on the fly while archiving. The parameter Mode
defines the archiving mode. If no mode is passed, the actual online value will be archived.
Valid values are:
- Min
- Max
- Average
- Increment
- Summation Second
- Summation Minute
- Summation Hour
4.2.5.1. Min
The mode Min calculates the minimum value within an archiving cycle. The archiving cycle is
defined in the column Cycle of the archive definition.
Example:
An archive has a cycle of 1 Hour, but every 10 seconds the value is written into the archive using
the mode Min. Therefore, the archive will contain one value per hour, namely the lowest of the
values archived within the hour.
18

4.2.5.2. Max
The mode Max calculates the maximum value within an archiving cycle. The archiving cycle is
defined in the column Cycle of the archive definition.
Example:
An archive has a cycle of 1 Hour, but every 10 seconds the value is written into the archive using
the mode Max. Therefore, the archive will contain one value per hour, namely the highest of the
values archived within the hour.
4.2.5.3. Average
The mode Average calculates the average value within an archiving cycle. The archiving cycle is
defined in the column Cycle of the archive definition.
Example:
An archive has a cycle of 1 Hour, but every 10 seconds the value is written into the archive using
the mode Average. Therefore, the archive will contain one value per hour, namely the average of
all the values archived within the hour.
4.2.5.4. Increment
The mode Increment calculates the increment of a counter value within an archiving cycle. The
archiving cycle is defined in column Cycle of the archive definition.
Example:
An archive has a cycle of 1 Hour. Once per hour the actual counter value is written into the archive
using the mode Increment. Therefore, the archive will contain one value per hour, namely the
increment of the counter within the hour.
4.2.5.5. Summation
If a counter value is to be logged but there is none, and only an online measurement value is
available, one of the modes Summation Second, Summation Minute or Summation Hour can
be used. The difference between the three modes is the time basis of the calculation.
Example:
A flow measurement sensor has a range of 0-100l/min and is connected to a PLC. Using the mode
Summation Minute a counter value will be calculated in liters out of the actual flow measurement
value with the time basis Minute.
Note!
The time basis of the summation second, minute or hour must match the measurement unit of
the sensor.
Note!
The precision of the summation calculation is normally lower compared to the precision of a
hardware counter. Factors influencing the precision are unsteady measurement values, tolerances of
the sensor and the PLC input card as well as the measurement cycle.
Nevertheless, summation of measurement values to gain counter values is cost effective and precise
enough for many applications.

19

4.3.

Sample Application

Archive Array Variable (1, Temperature 17T1, 2, 10 Milliseconds)


Archive Array Variable (1, Temperature 17T1, 2, 10 Milliseconds, Average)
A report shows a pressure trend graphic for each pressing process of a hydraulic press. One pressing
process takes 3 seconds. The trend shows one value every 5ms, in other words, 200 values per
second or 600 values per pressing event.
The PLC stores the 600 values in a buffer area and sets a data available bit if new data is available.
PLC Reports monitors the data available bit and, if new data is available, reads all 600 values
including the timestamp and writes them into the specified archive.

4.4.

Workflow of the Instruction

The instruction has the following workflow:


1. Read all values of the data array from the PLC.
2. Read the actual value of the timestamp variable from the PLC.
3. Calculate the value to be archived depending on the archiving mode.
4. Write the values into the archive.
5. Update the archive header data like change information, last values, timestamp and
checksums.

4.5.

Possible Errors

Error Message

Explanation and Possible Error Cause

Invalid Variable Index: xxx

The value of parameter 1 or 3 is not an integer


number
There was no variable definition with the
specified index found
This instruction only supports variables with at
least 2 array elements
The mode specified in parameter 5 is not
supported
The time period specified in parameter 4 is not
supported
The simulation of array variable values is not
supported
Error while reading the variable value from the
PLC. Depending on the error type, additional
information will be shown.
Error while reading passing the timestamp to the
variable. Depending on the error type, additional
information will be shown.
Error while reading the timestamp value from
the PLC. Depending on the error type, additional
information will be shown.
There was no archive definition with the name
specified in parameter 2 found.
Multiple instructions were trying to write to the
archive at the same time.
Possible cause 1: Error in the scheduling

There is no variable with index xxx defined


The variable with index: xxx is not an array
Parameter 5: The requested mode is not
supported
Invalid time period (Parameter 4)
The simulation mode does not support arrays
Error reading the array values from the PLC

Error passing the timestamp to the arrayvariable


Error reading the timestamp from the PLC

There is no archive named xxx defined


Writing to the archive is blocked by another
event

20

Error opening the archive

Error converting the value to Decimal

Buffer overflow while adding the value to the


write requests queue

definitions. More than one trigger with the same


trigger time was defined.
Possible cause 2: The performance of the
computer is too low when using fast archiving
cycles like 1 second. The formerly executed
trigger event has not finished prior to the next
event. This can occur e.g. while installing
windows updates, while performing virus scans
or while starting resource consuming
applications.
An error occurred while opening the archive.
Check the archive definition and the archives
database files as well as the access rights to the
storage paths.
The variable definition column Format or
Unit uses settings which lead to a result which
cannot be converted into the data format
Decimal. To archive variables, the value must
be converted into the data type Decimal.
Write requests are queued. The size of the write
buffer can be adjusted separately for each
report using the report settings.

21

5.

Archive Batch Index

5.1.

Description

The instruction Archive Batch Index reads a Batch ID from the PLC and checks if the value has
changed since the last time it was read. If the Batch ID has changed and is not equal to the specified
inactive value, a new batch record is created and written into the corresponding archive. If the actual
Batch ID is an empty string or equal to zero, no batch record is created.
The timestamps Batch Begin and Batch End can be created in two different ways:
1. The time and date when the Batch ID value change was recognized by PLC Reports
2. Timestamps read from the PLC using one variable for the Batch Begin timestamp and
optionally another variable for the Batch End timestamp.

5.2.

Parameters

The command requires at least 4 parameters: The index of the Batch ID variable to read, the name of
the archive to write the batch record into, the batch inactive constant and the timestamp mode.
Instead of the timestamp mode, a Batch Start Timestamp variable index and a Batch End
Timestamp variable index can be passed. If only a Batch Start Timestamp variable index is passed,
the batch record can be completed later using the instruction Archive Batch Index End.
5.2.1. Parameter 1: Index of the Batch ID Variable to Read
Valid values are indexes of defined variables. This parameter is always required.
5.2.2. Parameter 2: Archive Name
Valid values are names of defined archives. This parameter is always required.
5.2.3. Parameter 3: Batch Inactive Value
Valid are all values within the value range of the variables data type.
5.2.4. Parameter 4: Timestamp Mode or Index of the Batch Begin Timestamp Variable
Valid values are:
- Change Data
The time and date when the Batch ID value change was
recognized by PLC Reports is used.
- Now
The current report trigger timestamp is used.
- Index of a variable
The actual value of the specified variable is used. The variables data
type must be a type containing date and time.
5.2.5. Parameter 5: Index of the Batch End Timestamp Variable
- Valid values are indexes of defined variables. The variables data type must be a type
containing date and time. The parameter can be omitted to archive only the start time of the
Batch ID and finalize the record later.

22

5.3.

Sample Application

Archive Batch Index (1, BatchIDArchive, 0, Change Data)


Archive Batch Index (1, BatchIDArchive, Inactive, Change Data)
Archive Batch Index (1, BatchIDArchive, Inactive, 2, 3)
Archive Batch Index (1, BatchIDArchive, Inactive, 2)
Archive Batch Index (1, BatchIDArchive, Inactive, Now)
A batch report shows for each batch, running on a reactor, the corresponding measurement values
and equipment states, such as temperatures, pH values, conductivities, levels, valve positions, motor
feedbacks or recipe data.
The command Archive Batch Index is used to archive the Batch ID, the start and the end timestamp
of each batch. With the data of this records, archived values can be assigned to each corresponding
Batch ID at any time when creating a report.

5.4.

Workflow of the Instruction

The instruction has the following workflow:


1. Read the actual Batch ID from the PLC
2. Check if the Batch ID has changed
3. Check if the Batch ID equals the inactive constant, an empty string or zero
4. If the Batch ID has changes and is not inactive:
a. Read the start timestamp and optionally the end timestamp from the PLC
b. Archive a batch record containing the Batch ID, the start timestamp and optionally
the end time stamp
5. Update the archive header data like change information, last values, timestamp and
checksums.

5.5.

Possible Errors

Error Message

Explanation and Possible Error Cause

Invalid Batch ID Variable Index: xxx

The value of parameter 1 is not an integer


number.
There was no variable definition with the
specified index found.
Error while reading the variable value from the
PLC. Depending on the error type, additional
information will be shown.
Error converting the constant specified in
Parameter 3 into the data type of the Batch ID
variable
The timestamp mode specified in parameter 4
defines to use the change data of the Batch ID
variable but this data is not yet available. Before
this timestamp mode can be used, the change
data must be acquired using the command Get
Change Data
The value of parameter 4 is not an integer
number.
Error while reading the variable value from the
PLC. Depending on the error type, additional

There is no variable with index xxx defined


Error reading the Batch ID from the PLC

Error parsing the inactive value

Parameter Start: The value


'LastButOneValueChangedDateTime' is not
available. Get value by 'GetChangeData'
instruction first

Invalid Start Variable Index: xxx


Error reading the Start timestamp from the PLC

23

Error Message
Parameter Start: The value
'LastValueChangedDateTime' is not available.
Get value by 'GetChangeData' instruction first

Invalid End Variable Index: xxx


Error reading the End timestamp from the PLC

There is no archive named xxx defined


Writing to the archive is blocked by another
event

Error opening the archive

Error accessing the last index


Error converting the BatchID to string
Error converting the BatchID or the
InactiveValue to Int
Error archiving value
Buffer overflow while adding the value to the
write requests queue

Explanation and Possible Error Cause


information will be shown.
The timestamp mode specified in parameter 4
defines to use the change data of the Batch ID
variable but this data is not yet available. Before
this timestamp mode can be used, the change
data must be acquired using the command Get
Change Data
The value of parameter 4 is not an integer
number.
Error while reading the variable value from the
PLC. Depending on the error type, additional
information will be shown.
There was no archive definition with the name
specified in parameter 2 found.
Multiple instructions were trying to write to the
archive at the same time.
Possible cause 1: Error in the scheduling
definitions. More than one trigger with the same
trigger time was defined.
Possible cause 2: The performance of the
computer is too low when using fast archiving
cycles like 1 second. The formerly executed
trigger event has not finished prior to the next
event. This can occur e.g. while installing
windows updates, while performing virus scans
or while starting resource consuming
applications.
An error occurred while opening the archive.
Check the archive definition and the archives
database files as well as the access rights to the
storage paths.
Error in the archives data format. Please check if
the file was damaged
Error in the archives data format. Please check if
the file was damaged
Error in the archives data format. Please check if
the file was damaged
Error in the archives data format. Please check if
the file was damaged
Write requests are queued. The size of the write
buffer can be adjusted separately for each
report using the report settings.

24

6.

Archive Batch Index End

6.1.

Description

The instruction Archive Batch Index End reads a Batch ID from the PLC and searches for the
corresponding record within the specified batch index archive. If a record without an end timestamp
exists and the actual Batch ID is not an empty string and is not equal to zero, the record is completed
by writing the batch end timestamp into it.
The instruction Archive Batch Index End is used if only the Batch Begin data was archived by a
formerly executed Archive Batch Index instruction (Multi-Batch).
The timestamp Batch End can be created in two different ways:
1. The time and date when the Batch ID value change was recognized by PLC Reports
2. A timestamp read from the PLC using one variable for the Batch Begin timestamp and
optionally another variable for the Batch End timestamp.

6.2.

Parameters

The command requires 4 parameters: The index of the Batch ID variable to read, the name of the
archive to write the batch record into, the batch inactive constant and the timestamp mode. Instead
of the timestamp mode, a Batch End Timestamp variable index can be passed.
6.2.1. Parameter 1: Index of the Batch ID Variable to Read
Valid values are indexes of defined variables. This parameter is always required.
6.2.2. Parameter 2: Archive Name
Valid values are names of defined archives. This parameter is always required.
6.2.3. Parameter 3: Batch Inactive Value
Valid are all values within the value range of the variables data type.
6.2.4. Parameter 4: Timestamp Mode or Index of the Batch End Timestamp Variable
Valid values are:
- Change Data
The time and date when the Batch ID value change was
recognized by PLC Reports is used.
- Now
The current report trigger timestamp is used.
- Index of a variable
The actual value of the specified variable is used. The variables data
type must be a type containing date and time.

25

6.3.

Sample Application

Archive Batch Index End (1, BatchIDArchive, 0, Change Data)


Archive Batch Index End (1, BatchIDArchive, Inactive, Change Data)
Archive Batch Index End (1, BatchIDArchive, Inactive, 2)
Archive Batch Index End (1, BatchIDArchive, Inactive, Now)
A batch report shows for each batch, running on a reactor, the corresponding measurement values
and equipment states, such as temperatures, pH values, conductivities, levels, valve positions, motor
feedbacks or recipe data.
The command Archive Batch Index is used to archive the Batch ID, the start and the end timestamp
of each batch. With the data of this records, archived values can be assigned to each corresponding
Batch ID at any time when creating a report.

6.4.

Workflow of the Instruction

The instruction has the following workflow:


1. Read the actual Batch ID from the PLC
2. Check if the Batch ID equals the inactive constant, an empty string or zero
If yes, end instruction
3. Search for the corresponding Batch Index record within the specified Batch Index archive:
4. Write the end timestamp into the corresponding Batch Index record
5. Update the archive header data like change information, last values, timestamp and
checksums.

6.5.

Possible Errors

Error Message

Explanation and Possible Error Cause

Invalid Batch ID Variable Index: xxx

The value of parameter 1 is not an integer


number.
There was no variable definition with the
specified index found.
Error while reading the variable value from the
PLC. Depending on the error type, additional
information will be shown.
Error converting the constant specified in
Parameter 3 into the data type of the Batch ID
variable
The timestamp mode specified in parameter 4
defines to use the change data of the Batch ID
variable but this data is not yet available. Before
this timestamp mode can be used, the change
data must be acquired using the command Get
Change Data
The value of parameter 4 is not an integer
number.
Error while reading the variable value from the
PLC. Depending on the error type, additional
information will be shown.
The timestamp mode specified in parameter 4
defines to use the change data of the Batch ID

There is no variable with index xxx defined


Error reading the Batch ID from the PLC

Error parsing the inactive value

Parameter Start: The value


'LastButOneValueChangedDateTime' is not
available. Get value by 'GetChangeData'
instruction first

Invalid Start Variable Index: xxx


Error reading the Start timestamp from the PLC

Parameter Start: The value


'LastValueChangedDateTime' is not available.

26

Error Message

Explanation and Possible Error Cause

Get value by 'GetChangeData' instruction first

variable but this data is not yet available. Before


this timestamp mode can be used, the change
data must be acquired using the command Get
Change Data
The value of parameter 4 is not an integer
number.
Error while reading the variable value from the
PLC. Depending on the error type, additional
information will be shown.
There was no archive definition with the name
specified in parameter 2 found.
Multiple instructions were trying to write to the
archive at the same time.
Possible cause 1: Error in the scheduling
definitions. More than one trigger with the same
trigger time was defined.
Possible cause 2: The performance of the
computer is too low when using fast archiving
cycles like 1 second. The formerly executed
trigger event has not finished prior to the next
event. This can occur e.g. while installing
windows updates, while performing virus scans
or while starting resource consuming
applications.
An error occurred while opening the archive.
Check the archive definition and the archives
database files as well as the access rights to the
storage paths.
Error in the archives data format. Please check if
the file was damaged
Error in the archives data format. Please check if
the file was damaged
Error in the archives data format. Please check if
the file was damaged
Error in the archives data format. Please check if
the file was damaged
Write requests are queued. The size of the write
buffer can be adjusted separately for each
report using the report settings.

Invalid End Variable Index: xxx


Error reading the End timestamp from the PLC

There is no archive named xxx defined


Writing to the archive is blocked by another
event

Error opening the archive

Error accessing the last index


Error converting the BatchID to string
Error converting the BatchID or the
InactiveValue to Int
Error archiving value
Buffer overflow while adding the value to the
write requests queue

27

7.

Archive Variable

7.1.

Description

The instruction Archive Variable reads the variables actual online value from the PLC and writes it
into an archive. Different archiving modes are available.

7.2.

Parameters

The command requires at least 2 parameters: The index of the variable to read and the name of the
archive to write the value into. The archiving mode can be passes optionally.
7.2.1. Parameter 1: Index of the Variable to Read
Valid values are indexes of defined variables. This parameter is always required.
7.2.2. Parameter 2: Archive Name
Valid values are names of defined archives. This parameter is always required.
7.2.3. Parameter 3: Mode
Several calculation functions can be performed on the fly while archiving. The parameter Mode
defines the archiving mode. If no mode is passed, the actual online value will be archived.
Valid values are:
- Min
- Max
- Average
- Increment
- Summation Second
- Summation Minute
- Summation Hour
- OEE Time
- OEE %Time
7.2.3.1. Min
The mode Min calculates the minimum value within an archiving cycle. The archiving cycle is
defined in the column Cycle of the archive definition.
Example:
An archive has a cycle of 1 Hour, but every 10 seconds the value is written into the archive using
the mode Min. Therefore, the archive will contain one value per hour, namely the lowest of the
values archived within the hour.
7.2.3.2. Max
The mode Max calculates the maximum value within an archiving cycle. The archiving cycle is
defined in the column Cycle of the archive definition.
Example:
An archive has a cycle of 1 Hour, but every 10 seconds the value is written into the archive using
the mode Max. Therefore, the archive will contain one value per hour, namely the highest of the
values archived within the hour.

28

7.2.3.3. Average
The mode Average calculates the average value within an archiving cycle. The archiving cycle is
defined in the column Cycle of the archive definition.
Example:
An archive has a cycle of 1 Hour, but every 10 seconds the value is written into the archive using
the mode Average. Therefore, the archive will contain one value per hour, namely the average of
all the values archived within the hour.
7.2.3.4. Increment
The mode Increment calculates the increment of a counter value within an archiving cycle. The
archiving cycle is defined in column Cycle of the archive definition.
Example:
An archive has a cycle of 1 Hour. Once per hour the actual counter value is written into the archive
using the mode Increment. Therefore, the archive will contain one value per hour, namely the
increment of the counter within the hour.
7.2.3.5. Summation
If a counter value is to be logged but there is none, and only an online measurement value is
available, one of the modes Summation Second, Summation Minute or Summation Hour can
be used. The difference between the three modes is the time basis of the calculation.
Example:
A flow measurement sensor has a range of 0-100l/min and is connected to a PLC. Using the mode
Summation Minute a counter value will be calculated in liters out of the actual flow measurement
value with the time basis Minute.
Note!
The time basis of the summation second, minute or hour must match the measurement unit of
the sensor.
Note!
The precision of the summation calculation is normally lower compared to the precision of a
hardware counter. Factors influencing the precision are unsteady measurement values, tolerances of
the sensor and the PLC input card as well as the measurement cycle.
Nevertheless, summation of measurement values to gain counter values is cost effective and precise
enough for many applications.

29

7.2.3.6. OEE Time


The mode OEE Time archives the time period in which a plant or machine is in a certain condition.
Parameter 4 defines a comparison value which is used to verify if the plant or machine is in the
desired condition.
Example:
A reports shows a machines OEE (Overall Equipment Effectiveness). The machine conditions, such as
maintenance, fault, product change, tool change, lack of product, production, shift change, etc., are
defined. A variable within the machines PLC is indicating the current machine condition.
The instruction Archive Variable (1, ArchiveUnscheduledProductChange, OEE Time, 4) reads the
variable with index 1 from the PLC and checks if the value is 4. If the variables value is 4, in other
words the machine is in condition Unscheduled Product Change, the duration of one trigger
interval is added to the current cycle value of the archive ArchiveUnscheduledProductChange.
The desired reporting accuracy as well as the amount of data can be adjusted by the archives cycle
and the archiving interval.
If, for instance, an archive cycle of 1 hour is used and the variable is archived every 10 seconds, the
report can show for each machine condition at maximum 1 value per hour with an accuracy of 10
seconds.
7.2.3.7. OEE %Time
The mode OEE %Time works exactly like the mode OEE Time with the difference that the values
are archives as percentage-of-time-periods instead of time durations.
Example:
A machine condition is written into an archive with a cycle of one hour. Within one hour, the
machine was in condition Unscheduled Product Change for 20 minutes. In this case, the result of
the calculation is 33.3%.

7.3.

Sample Application

Archive Variable (1, Temperature 17T1)


A daily report shows the trend of the temperature 17T1. For this purpose, a variable with index 1 is
defined. An event defined in section Scheduling triggers the instruction Archive Variable once per
minute. By this, the actual temperature (variable with index 1) is being read from the PLC and written
into the archive Temperature 17T1. Every day at 11:59:59 PM a further event starts the report
creation and reads all archived values of the day from the archive and writes them into the report.

7.4.

Workflow of the Instruction

The instruction has the following workflow:


1. Read the actual value from the PLC.
2. Calculate the value to be archived depending on the archiving mode.
3. Write the value into the archive.
4. Update the archive header data like change information, last values, timestamp and
checksums.

30

7.5.

Possible Errors

Error Message

Explanation and Possible Error Cause

Invalid Variable Index: xxx

The value of parameter 1 is not an integer


number.
There was no variable definition with the
specified index found.
The mode specified in parameter 3 is not
supported.
Error while reading the variable value from the
PLC. Depending on the error type, additional
information will be shown.
There was no archive definition with the name
specified in parameter 2 found.
Multiple instructions were trying to write to the
archive at the same time.
Possible cause 1: Error in the scheduling
definitions. More than one trigger with the same
trigger time was defined.
Possible cause 2: The performance of the
computer is too low when using fast archiving
cycles like 1 second. The formerly executed
trigger event has not finished prior to the next
event. This can occur e.g. while installing
windows updates, while performing virus scans
or while starting resource consuming
applications.
An error occurred while opening the archive.
Check the archive definition and the archives
database files as well as the access rights to the
storage paths.
The variable definition column Format or
Unit uses settings which lead to a result which
cannot be converted into the data format
Decimal. To archive variables, the value must
be converted into the data type Decimal.
Write requests are queued. The size of the write
buffer can be adjusted separately for each
report using the report settings.

There is no variable with index xxx defined


Parameter 3: The requested mode is not
supported
Error reading the value from the PLC

There is no archive named xxx defined


Writing to the archive is blocked by another
event

Error opening the archive

Error converting the value to Decimal

Buffer overflow while adding the value to the


write requests queue

31

8.

Check Negative Edge

8.1.

Description

The command Check Negative Edge checks if a Boolean archive value has changed its state from
True to False. The value of the last archive cycle is being compared with the value of the current
cycle.
The logical result of the command can be used in subsequent instructions, e.g. to perform a
conditional jump using the Go To if Yes command.
PLC Reports provides a logical result bit for each instruction list. Check-instructions write their
results into the logical result bit. Conditional commands, especially the Go To if Yes/No commands,
evaluate this result.

8.2.

Parameters

The command requires one parameter: The name of the archive to be checked.
8.2.1. Parameter 1: Archive Name
Valid values are the names of archives defined in the report file. This parameter is always required.

8.3.

Sample Application

Check Positive Edge (ArchiveName)


In a production, a batch report has to be created for each completed batch. The batch program
provides a bit with the value 1 if a batch is running and the value 0 if the batch is not running.
A Boolean variable represents the state of the batch. An archive with a suitable cycle, e.g. 10 sec, is
used to archive the batch-is-running information. The instruction Check Negative Edge checks
whether or not a batch is completed and if yes, the batch report is created.

8.4.

Workflow of the Instruction

The instruction has the following workflow:


1. Read the actual value from the archive.
2. Read the value of the last cycle from the archive.
3. Check if the last value was 1 and the actual value is 0
a. If yes: Set the logical result to True.
b. If no: Set the logical result to False.

8.5.

Possible Errors

Error Message

Explanation and Possible Error Cause

There is no archive named xxx defined

The report template contains no archive


definition with the name specified in parameter
1
The actual value could not be converted into a
Boolean.

Error converting the actual value to a Boolean

32

9.

Check New Period

9.1.

Description

The command Check New Period checks if a new time period has begun. The time period to check
is specified in the parameter and is checked against the scheduled start time. The result of the test is
being written into the logical result bit of the current instruction list and can be used subsequently
for conditional jumps.
Note!
This command is designed for special tasks only. The use of scheduling triggers is recommended
whenever possible.

9.2.

Parameters

The command requires one parameter: The time period to be checked.


9.2.1.
-

Parameter 1: Time Range


Minute
Checks if a new minute has begun.
Hour
Checks if a new hour has begun.
Day
Checks if a new day has begun.
Week
Checks if a new week has begun.
Month
Checks if a new month has begun.
Year
Checks if a new year has begun.

9.3.

Sample Application

Check New Period (Month)


In addition to the scheduling, the command provides another possibility for the conditional execution
of instructions based on time periods.

9.4.

Workflow of the Instruction

The instruction has the following workflow:


1. Compare the start time of the event with the time period to check
a. If a new period has begun: Set the logical result to True.
b. If not: Set the logical result to False.

9.5.

Possible Errors

Error Message

Explanation and Possible Error Cause

Unknown time unit

The time unit specified in parameter 1 is invalid.

33

10.

Check Positive Edge

10.1. Description
The command Check Positive Edge checks if a Boolean archive value has changed its state from
False to True. The value of the last archive cycle is being compared with the value of the current
cycle.
The logical result of the command can be used in subsequent instructions, e.g. to perform a
conditional jump using the Go To if Yes command.
PLC Reports provides a logical result bit for each instruction list. Check-instructions write their
results into the logical result bit. Conditional commands, especially the Go To if Yes/No commands,
evaluate this result.

10.2. Parameters
The command requires one parameter: The name of the archive to be checked.
10.2.1. Parameter 1: Archive Name
Valid values are the names of archives defined in the report file. This parameter is always required.

10.3. Sample Application


Check Positive Edge (Archive1)
A storage tank stores a compound used in a production line. If the tank is almost empty, it is being
refilled by a tank truck. Between two filling tasks, the compound is supplied from the tank. The
consumption data between the filling tasks is to be reported.
A Boolean variable is used to read the status of the filling valve, open or closed, from the PLC. An
archive with a suitable cycle, e.g. 30 sec, is used to archive the status of the filling valve. The
instruction Check Positive Edge checks if the valve was opened and if yes, the following instruction
Go To if Yes jumps to the part of the instruction list responsible for the report creation. If there is
no positive edge it means that no new filling cycle has started and the current instruction list will be
ended.

10.4. Workflow of the Instruction


The instruction has the following workflow:
1. Read the actual value from the archive.
2. Read the value of the last cycle from the archive.
3. Check if the last value was 0 and the actual value is 1
a. If yes: Set the logical result to True.
b. If no: Set the logical result to False.

10.5. Possible Errors


Error Message

Explanation and Possible Error Cause

There is no archive named xxx defined

The report template contains no archive


definition with the name specified in parameter
1
The actual value could not be converted into a
Boolean.

Error converting the actual value to a Boolean

34

11.

Check Value Change

11.1. Description
The command Check Value Change checks if an archive value has changed since the last archive
cycle. The test result is written into the logical result bit of the current instruction list and can be
used in subsequent instructions, e.g. to perform a conditional jump using the Go To if Yes
command.
PLC Reports provides a logical result bit for each instruction list. Check-instructions write their
results into the logical result bit. Conditional commands, especially the Go To if Yes/No commands,
evaluate this result.

11.2. Parameters
The command requires one parameter: The name of the archive to be checked.
11.2.1. Parameter 1: Archive Name
Valid values are the names of archives defined in the report file. This parameter is always required.

11.3. Sample Application


Check Value Change (Archive1)
In a production, a report has to be created for each completed batch. For triggering the report no
batch-active-bit can be used because when a batch is finished the next batch follows seamlessly.
However, the batch program provides a batch ID containing a new value for each new batch.
A variable represents the actual batch ID and an archive with a suitable cycle, e.g. 10 sec, is used to
archive the batch ID. The instruction Check Value Change checks whether or not a new batch has
started (the batch ID changed) and if yes, the following instruction Go To if Yes jumps to the part of
the instruction list responsible for the report creation. If there is no value change of the batch ID it
means that the batch is not completed and the current instruction list will be ended.

11.4. Workflow of the Instruction


The instruction has the following workflow:
1. Read the actual value from the archive.
2. Read the value of the last cycle from the archive.
3. Check if the last value was different than the actual value.
a. If yes: Set the logical result to True.
b. If no: Set the logical result to False.

11.5. Possible Errors


Error Message

Explanation and Possible Error Cause

There is no archive named xxx defined

The report template contains no archive


definition with the name specified in parameter
1

35

12.

Check Variable Value Change

12.1. Description
The command Check Variable Value Change checks if a variable value has changed. The command
compares the last changed value with the actual online one. The test result is written into the logical
result bit of the current instruction list and can be used in subsequent instructions, e.g. to perform a
conditional jump using the Go To if Yes command.
PLC Reports provides a logical result bit for each instruction list. Check-instructions write their
results into the logical result bit. Conditional commands, especially the Go To if Yes/No commands,
evaluate this result.

12.2. Parameters
The command requires at least two parameters: The index of the variable to be checked and the
dead band. Optionally, an inactive value and a flag, indicating if the value following an inactive value
is counted as change, can be passed.
12.2.1. Parameter 1: Variable Index
Valid values are the indices of variables defined in the report file. This parameter is always required.
12.2.2. Parameter 2: Dead Band
Valid values are the indices of variables defined in the report file. This parameter is always required.
12.2.3. Parameter 3: Inactive Value
This optional parameter defines a value indicating an inactive state.
12.2.4. Parameter 4: Value Following an Inactive Value is a Change (Yes/No)
This optional parameter defines if the value following an inactive value is interpreted as a change.
Valid values are
- Yes
- No
- True
- False

12.3. Sample Application


Check Variable Value Change (1, 0.3)
Check Variable Value Change (1, 0.3, 0)
Check Variable Value Change (1, 0.3, 0, Yes)
A scale measures the weight of each production batch. After each weighing the scale shows the
result in a variable for a certain time. If no new measurement value is available, the variable value is
0. PLC Reports monitors the variable for changes. Whenever a new value unequal to 0 is
recognized, PLC Reports archives the value using the instructions Go To If Yes and Archive
Variable.

36

12.4. Workflow of the Instruction


The instruction has the following workflow:
1. Read the variable value from the PLC
2. Check if the value equals the inactive value
If yes, end the command with logical result No
3. Check if the value has changed after an inactive value was recognized
a. If yes and parameter 4 = no, end the command with logical result to No
4. Check if the value has changed
If yes, End the command with logical result to Yes
If no, End the command with logical result to No

12.5. Possible Errors


Error Message

Explanation and Possible Error Cause

Invalid variable index

The variable index specified in parameter 1 is


not an integer.
The index specified in parameter 1 is an integer
number but no variable with that index is
defined.
An error occurred while reading the variable
from the PLC. Further details can be found in the
message list.
The value specified in parameter 2 is not a
number
The command supports numeric data types only

There is no variable with index: xxx defined

Error reading the value from the PLC

Dead band is not a number


The data type of the variable is not supported by
this command
Error comparing the value

Error comparing the value. Further details can be


found in the message list.

37

13.

Check Working Copy

13.1. Description
The command Check Working Copy checks if a working copy is available and if it is up-to-date. The
parameter passed defines how old a working copy may be at maximum.
In addition to the use of archives it is possible to write data directly into a report file. In this case, at
each scheduling event the report file is being opened, the data is added and the report file is saved.
At the end of a reporting period the report is finalized and moved into the final output directory. A
working copy is always used to create reports. The advantage is that reports are available at any
time, even in the middle of a reporting period. Example: One monthly value is added every month to
an annual report.
Note!
For storing historical values using archives is recommended whenever possible. Nevertheless, in
some special cases it might be necessary to work directly with the Excel report files.
Note!
For logging values directly into a report file, without the use of archives, only cycles >=1 minute are
supported.

13.2. Parameters
The command requires one parameter: The maximum age of the report file.
13.2.1. Parameter 1: Maximum Age
Valid values are:
1 Second
Not older than 1 Second
100 Seconds
Not older than 100 Seconds
1 Minute
100 Minutes
This Minute
Previous Minute

Not older than 1 Minute


Not older than 100 Minutes
Created this Minute
Created this or in the previous Minute

1 Hour
100 Hours
This Hour
Previous Hour

Not older than 1 Hour


Not older than 100 Hours
Created this Hour
Created this or in the previous Hour

1 Day
100 Days
This Day
Previous Day

Not older than 1 Day


Not older than 100 Days
Created this Day
Created this or on the previous Day

1 Week
100 Weeks
This Week
Previous Week

Not older than 1 Week


Not older than 100 Weeks
Created this Week
Created this or in the previous Week
38

1 Month
100 Months
This Month
Previous Month

Not older than 1 Month


Not older than 100 Months
Created this Month
Created this or in the previous Month

1 Year
100 Years
This Year
Previous Year

Not older than 1 Year


Not older than 100 Years
Created this Year
Created this or in the previous Year

13.3. Sample Application


Check Working Copy (This Month)
To check if a working copy, created within the actual month, exists in the output directory, the
command Check Working Copy (This Moth) is being used.

13.4. Workflow of the Instruction


The instruction has the following workflow:
1. Check if a working copy exists in the output directory.
a. If no: Set the logical result to False and exit.
2. Check if the creation date of the working lies within the time period specified in parameter 1.
a. If no: Set the logical result to False.
b. If yes: Set the logical result to True.

13.5. Possible Errors


Error Message

Explanation and Possible Error Cause

Invalid parameter syntax: Timespan

The timespan specified in parameter 1 is not in a


correct format.
The report setting Output Directory is not
defined correctly.
An error occurred while trying to access the
report file. Further details can be found in the
message list.

The setting 'OutputDirectory' is not accessible


Error accessing the report file

39

14.

Clean Report

14.1. Description
The command Clean Reports deletes the worksheets Settings, Variable, Archives,
Instructions and Scheduling from the actual report file.
Note!
The command can only be executed if the report file is opened.

14.2. Parameters
None

14.3. Sample Application


Clean Report ()
After completion, a report has to contain the main worksheets Data and Report only. For this
purpose, the worksheets used for the definition of settings, variables, archives, instructions and
scheduling are deleted by calling the command Clean Report after filling the report with data.

14.4. Workflow of the Instruction


The instruction has the following workflow:
1. Delete the worksheet Settings.
2. Delete the worksheet Variables.
3. Delete the worksheet Archives.
4. Delete the worksheet Instructions.
5. Delete the worksheet Scheduling.

40

14.5. Possible Errors


Error Message

Explanation and Possible Error Cause

The working copy is not opened

The command can only be executed if the report


file was opened before.
While deleting the worksheets, Excel inquiries
are disabled. An error occurred while disabling
the inquiries. Further error details can be found
in the message list.
An error occurred while deleting the worksheet
Settings. Further error details can be found in
the message list.
An error occurred while deleting the worksheet
Variables. Further error details can be found in
the message list.
An error occurred while deleting the worksheet
Archives. Further error details can be found in
the message list.
An error occurred while deleting the worksheet
Instructions. Further error details can be found
in the message list.
An error occurred while deleting the worksheet
Scheduling. Further error details can be found
in the message list.
After deleting the worksheets, Excel inquiries are
re-enabled. An error occurred while enabling the
inquiries. Further error details can be found in
the message list.

Error disabling alerts

Error deleting the sheet 'Settings'

Error deleting the sheet Variables

Error deleting the sheet Archives

Error deleting the sheet Instructions

Error deleting the sheet Scheduling

Error enabling alerts

41

15.

Close Report File

15.1. Description
After a report was opened and filled with data the working copy of the report needs to be closed.
The command Close Report File closes the actual working copy of the report. This command is
mainly used if the data is written repeatedly into the same report file without the use of archives.
Note!
If a report is finally saved using the command Save Final Report File, explicit closing of the report
file is not necessary because this task is already performed by the command Save Final Report File.

15.2. Parameters
None

15.3. Sample Application


Close Report File ()
If a report does not use archives and values are written repeatedly into the same report file over a
certain period of time, the report file has to be closed between two writing events using the
command Close Report File.

15.4. Workflow of the Instruction


The instruction has the following workflow:
1. Close the actual working copy of the report.
2. Set the report file to Read Only

15.5. Possible Errors


Error Message

Explanation and Possible Error Cause

Error closing the working copy

An error occurred while closing the working copy


of the report file. Further details can be found in
the message list.
The report setting Output Directory is not
defined correctly.
An error occurred while closing the report file.
Further details can be found in the message list.

The setting 'OutputDirectory' is not accessible


The working copy of the report file is not
accessible

42

16.

Compare Two Variables

16.1. Description
The command Compare Two Variables compares the values of two variables. Different comparing
operands can be used.
The logical result of the command can be used in subsequent instructions, e.g. to perform a
conditional jump using the Go To if Yes command.
PLC Reports provides a logical result bit for each instruction list. Check-instructions write their
results into the logical result bit. Conditional commands, especially the Go To if Yes/No commands,
evaluate this result.

16.2. Parameters
The command always requires one parameter: The comparison expression.
16.2.1. Parameter 1: Comparison Expression
Structure of the comparison expression:
Variable-Index-1 Operand Variable-Index-2
Example:
10 >= 11 (Compare the value of the variable with index 10* with value of the variable with index 11*)
* A variable with the specified index must be defined.
Valid operands are:
- <=
Compare if less or equal
- >=
Compare if greater or equal
- !=
Compare if not equal
- =
Compare if equal
- <
Compare if less
- >
Compare if greater

16.3. Sample Application


Compare Two Variables (10 >= 11)
Compare the value of the variable with index 10 with value of the variable with index 11.
The command can be used to perform conditional actions depending on variable values.

16.4. Workflow of the Instruction


The instruction has the following workflow:
1. Check the syntax.
2. Check if actual online values are available, if no, read the values from the PLC.
3. If actual online values exist, use these values.
4. Compare the value of variable 1 with the value of variable 2 according to the comparison
expression.
5. Set the logical result bit according to the result of the comparison to True or False.

43

16.5. Possible Errors


Error Message

Explanation and Possible Error Cause

Syntax error

Check the syntax of parameter 1:


Index Operand Constant
One of the specified indexes in parameter 1 is
not a number.
There was no variable definition with the
specified index found.
Error while reading the variable value 1 from the
PLC. Depending on the error type, additional
information will be shown.
Error while reading the variable value 2 from the
PLC. Depending on the error type, additional
information will be shown.
Check the formatting settings of column
Format and Unit and make sure that the
formatting result can be converted into a
number.
The constant specified in parameter 1 is not a
number.
The comparison operand specified in parameter
1 is invalid.

Invalid variable index


There is no variable with index xxx defined
Error reading variable 1 from the PLC

Error reading variable 2 from the PLC

Error converting the actual value of the variable


into a number

Error converting the constant into a number


Unknown comparison operand

44

17.

Compare Variable

17.1. Description
The command Compare Variable compares the value of the variable with a constant. Different
comparing operands can be used.
The logical result of the command can be used in subsequent instructions, e.g. to perform a
conditional jump using the Go To if Yes command.
PLC Reports provides a logical result bit for each instruction list. Check-instructions write their
results into the logical result bit. Conditional commands, especially the Go To if Yes/No commands,
evaluate this result.

17.2. Parameters
The command always requires one parameter: The comparison expression.
17.2.1. Parameter 1: Comparison Expression
Structure of the comparison expression:
Variable-Index Operand Constant
Example:
10 >= 1,000 (Compare the value of the variable with index 10* with the constant 1,000)
* A variable with the specified index must be defined.
Valid operands are:
- <=
Compare if less or equal
- >=
Compare if greater or equal
- !=
Compare if not equal
- =
Compare if equal
- <
Compare if less
- >
Compare if greater

17.3. Sample Application


Compare Variable(10 >= 1,000)
Compare the value of the variable with index 10 with the constant 1,000.
The command can be used to perform conditional actions depending on a variable value.

17.4. Workflow of the Instruction


The instruction has the following workflow:
1. Check the syntax.
2. Check if an actual online value is available, if no, read the value from the PLC.
3. If an actual online value exists, use this value.
4. Compare the variable value with the constant according to the comparison expression.
5. Set the logical result bit according to the result of the comparison to True or False.

45

17.5. Possible Errors


Error Message

Explanation and Possible Error Cause

Syntax error

Check the syntax of parameter 1:


Index Operand Constant
There was no variable definition with the
specified index found.
Error while reading the variable value from the
PLC. Depending on the error type, additional
information will be shown.
Check the formatting settings of column
Format and Unit and make sure that the
formatting result can be converted into a
number.
The constant specified in parameter 1 is not a
number.
The comparison operand specified in parameter
1 is invalid.

There is no variable with index xxx defined


Error reading the variable from the PLC

Error converting the actual value of the variable


into a number

Error converting the constant into a number


Unknown comparison operand

46

18.

Copy Variable

18.1. Description
The command Copy Variable copies the actual value of one variable into another variable.

18.2. Parameters
The command always requires two parameters: The index of the source and the index of the
destination variable.
18.2.1. Parameter 1: Source Variable Index
Valid values are the indices of variables defined in the report file. This parameter is always required.
18.2.2. Parameter 2: Destination Variable Index
Valid values are the indices of variables defined in the report file. This parameter is always required.

18.3. Sample Application


Copy Variable (1, 2)
The command is used to copy the value of one variable into another variable. It can also be used for
data type conversion.

18.4. Workflow of the Instruction


The instruction has the following workflow:
Copy the value of the source into the destination variable

18.5. Possible Errors


Error Message

Explanation and Possible Error Cause

Invalid source variable index

The variable index specified in parameter 1 is


not an integer.
The index specified in parameter 1/2 is an
integer number but no variable with that index is
defined.
The variable index specified in parameter 2 is
not an integer.
The source variable has no actual value
Error copying the value. Further details can be
found in the message list.

There is no variable with index: xxx defined

Invalid destination variable index


The source variable has no actual value
Error copying the variable value

47

19.

Create New Report File

19.1. Description
The command Create New Report File creates a new copy of the report definition file and saves it
in the base output directory (Output directory without subfolders for days, weeks, month or years).
The name of the working copy is set to the original filename of the report template plus the
extension Working.
If another working copy exists in the output directory, it will be moved into the final output directory
and the extension Working will be replaced by Cancelled.
19.1.1. Output Directory
The setting Output Directory, defined in the report settings, specifies the directory to be used for
report creation and serves as the working directory at the same time. In addition, it is possible to
define whether or not subfolders for days, weeks, months or years should be created.
19.1.2. Final Output Directory
The final output directory depends on the above mentioned setting.
Example: Supposing that the output directory is set to D:\Reports and subfolders for years, months
and days are being used, on July 22, 2010 the final directory would be D:\Reports\2010\07\22.
Note!
Use local drives only!
If network drives are used, the performance of PLC Reports will be unpredictable. Time critical tasks
like logging variables can be unexpectedly delayed. Queuing of events caused by bad or not-at-all
reachable network locations might cause critical errors and can also lead to the loss of the data.

19.2. Parameters
None

19.3. Sample Application


Create New Report File ()
The command is always used if new reports have to be created.

19.4. Workflow of the Instruction


The instruction has the following workflow:
1. Check and create subfolders according to the output directory settings.
2. Check if a working copy exists in the output directory.
a. If yes, move the working copy to the final output directory and mark it with the
actual date and time plus Cancelled.
3. Copy the report file to the output directory. Mark it with Working.

48

19.5. Possible Errors


Error Message

Explanation and Possible Error Cause

The setting 'Output Directory' is not available.


Abort

The setting Output Directory is not defined in


the report template. The current instruction list
will be aborted.
At least one of the settings Create Daily
Subfolder, Create Weekly Subfolder, Create
Monthly Subfolder or Create Annual
Subfolder is not defined in the report template.
An error occurred while moving the working
copy to the final output directory. The current
instruction list will be aborted. Further error
details can be found in the message list.

The settings 'CreateXXXSubfolder' are not


available.

Error moving the working copy to the final


destination. Abort

49

20.

Disable Trigger Warning

20.1. Description
PLC Reports doesnt allow the same scheduling event to start again before an earlier event has
finished execution. This is important to prevent queuing of events or even processor overloads for
instance while installing windows updates or while starting resource consuming applications.
In case trigger events are queued, a warning message is created.
Nevertheless, in some applications it might be necessary to disable specific warning messages.
The command Disable Trigger Warning disables all trigger warnings of the currently executed
instruction list until the execution has ended.

20.2. Parameters
None

20.3. Sample Application


Disable Trigger Warning ()
A batch report is created immediately after a batch has finished. For this purpose, a variable,
indicating if the batch has finished, is monitored every second. Whenever a batch has finished, a new
batch report is generated. But since the report creation will take longer than one second, the trigger
warning is disabled until the report generation has finished.

20.4. Workflow of the Instruction


The instruction has the following workflow:
1. Disable all trigger warnings of the currently executed instruction list

50

21.

Delete Report File

21.1. Description
The command Delete Report File closes and deletes the working copy of the report and is used if
the final report is required in PDF format only. After creating a PDF report (Instruction Save Report
as PDF) the Excel working copy of the report can be deleted if no Excel version of the report is
needed.
Note!
Virus scanners might delay the command for several seconds.

21.2. Parameters
None

21.3. Sample Application


Delete Report File ()
If a report is needed in PDF format only, the Excel version of the report is being deleted.

21.4. Workflow of the Instruction


The instruction has the following workflow:
1. Close the working copy of the report if open.
2. Delete the working copy.

21.5. Possible Errors


Error Message

Explanation and Possible Error Cause

Error deleting the working copy

An error occurred while deleting the working


copy. Further details can be found in the
message list.

51

22.

Exit

22.1. Description
The command Exit stops the execution of the current instruction list. Make sure that the report file
was saved and closed properly before calling the Exit instruction.
The command Exit can be called either at the end of an instruction list or at any other position. By
using the commands Go To If Yes or Go To If No the Exit command can be skipped or called
conditionally.

22.2. Parameters
None

22.3. Sample Application


Exit ()
The command Exit is always used to end the execution of the actual instruction list. Furthermore, it
can be used as jump destination for Go To commands.

22.4. Workflow of the Instruction


The instruction has the following workflow:
1. Check if the current report file is still opened.
a. If yes, force saving and closing the report.
2. End the instruction list execution.

22.5. Possible Errors


Error Message

Explanation and Possible Error Cause

The command Exit() was called but the working


copy of the report is still open

Before calling End the current report file must


be saved and closed. The command End was
called while the current report file was still open.
The command End was called while the
current report file was still open. Therefore,
saving the report file was forced but an error
occurred while saving it. Further error details
can be found in the message list.
The command End was called while the
current report file was still open. Therefore,
closing the report file was forced but an error
occurred while closing it. Further error details
can be found in the message list.
The command End was called but an archive
was still locked for writing. Closing the archive
was forced.

Error saving the report file

Error closing the report file

Releasing the archives write protection was


forced

52

23.

Get Change Data

23.1. Description
The instruction Get Change Data reads information about the last and the last but one value
change from an archive. The following data is read from the archive and provided for the subsequent
instructions:
- Last value
- Timestamp of the last value change
- Last but one value
- Timestamp of the last but one value change

23.2. Parameters
The command always requires one parameter: The name of the archive.
23.2.1. Parameter 1: Archive Name
Valid values are the archive names defined in the report. This parameter is always required.

23.3. Sample Application


Get Change Data (Archive1)
In a production, a batch report has to be created for each completed batch. The batch program
provides a bit with the value 1 if a batch is running and the value 0 if the batch is not running.
A Boolean variable represents the state of the batch. An archive with a suitable cycle, e.g. 10 sec, is
used to archive the batch-is-running information. The instruction Check Negative Edge checks
whether or not a batch is completed and if yes, the batch report is created. But the batch report
must show only the data logged while the batch was active, in other words, the data between the
start and the end of the last batch. At the time of the negative edge, the batch-active-bit-archive
provides exactly this data:
- The last but one value change has the value True The batch started.
- The timestamp of the last but one value change is the timestamp of the last batch start.
- The last value change has the value False The batch ended.
- The timestamp of the last value change is the timestamp of the last batch end.
The same approach can be used to watch the change of a batch ID. By using the command Get
Change Data the data of the last batch can be output in the same way, but based on a batch ID, and
not on a batch active bit.

23.4. Workflow of the Instruction


The instruction has the following workflow:
1. Read the last changed archive value
2. Read the timestamp of the last changed archive value
3. Read the last but one changed archive value
4. Read the timestamp of the last but one changed archive value

53

23.5. Possible Errors


Error Message

Explanation and Possible Error Cause

There is no archive named xxx defined

There was no archive definition with the


specified name found.
An error occurred while opening the archive.
Further details can be found in the message list.

Error opening the archive

54

24.

Go To

24.1. Description
The command Go To jumps to the instruction with the specified index.

24.2. Parameters
The command requires one parameter: The index of the instruction to jump to.
24.2.1. Parameter 1: Instruction Index
Parameter 1 specifies the index of the instruction to jump to.
Valid values are indexes of instructions defined in the report template. This parameter is always
required.

24.3. Sample Application


Go To (10)
The command can be used to jump over one or more instructions in the list. By calling the Go To
command, the instruction list execution will be continued at the command with the specified index.

24.4. Workflow of the Instruction


The instruction has the following workflow:
1. Jump to the instruction with the index specified in parameter 1.

24.5. Possible Errors


Error Message

Explanation and Possible Error Cause

The value of parameter 1 is not a valid Indexnumber. Abort

The value of parameter 1 is not a valid integer


number. The instruction list execution will be
aborted.
The index specified in parameter 1 is not a valid
instruction index of the report template. The
instruction list execution will be aborted.

No instruction with the specified index exists.


Abort

55

25.

Go To If No

25.1. Description
The command Go To If No is used in combination with a comparison instruction, e.g. Compare
Variable. It checks the logical result bit of the actual instruction list which was set by a formerly
executed command.
If the state of the logical result bit is False, the command jumps to the instruction with the
specified index.
If the state of the logical result bit is True, the command is ended without taking any action.

25.2. Parameters
The command requires one parameter: The index of the instruction to jump to.
25.2.1. Parameter 1: Instruction Index
Parameter 1 specifies the index of the instruction to jump to.
Valid values are indexes of instructions defined in the report template. This parameter is always
required.

25.3. Sample Application


Go To If No (10)
An action has to be executed in a report if a variable doesnt have a certain value. For this purpose,
the value of the variable is read from the PLC and compared using the command Compare
Variable. The comparison command sets the logical result bit according to the result of the
comparison. If the logical result is False, the execution of the instruction list will jump to the
command with the specified index.

25.4. Workflow of the Instruction


The instruction has the following workflow:
1. Check the logical result bit
a. If False, jump to the instruction with the index specified in parameter 1.
b. If True, end the command without taking any action.

25.5. Possible Errors


Error Message

Explanation and Possible Error Cause

The value of parameter 1 is not a valid Indexnumber. Abort

The value of parameter 1 is not a valid integer


number. The instruction list execution will be
aborted.
The index specified in parameter 1 is not a valid
instruction index of the report template. The
instruction list execution will be aborted.

No instruction with the specified index exists.


Abort

56

26.

Go To If Yes

26.1. Description
The command Go To If Yes is used in combination with a comparison instruction, e.g. Compare
Variable. It checks the logical result bit of the actual instruction list which was set by a formerly
executed command.
If the state of the logical result bit is True, the command jumps to the instruction with the specified
index.
If the state of the logical result bit is False, the command is ended without taking any action.

26.2. Parameters
The command requires one parameter: The index of the instruction to jump to.
26.2.1. Parameter 1: Instruction Index
Parameter 1 specifies the index of the instruction to jump to.
Valid values are indexes of instructions defined in the report template. This parameter is always
required.

26.3. Sample Application


Go To If Yes (10)
An action has to be executed in a report if a variable has a certain value. For this purpose, the value
of the variable is read from the PLC and compared using the command Compare Variable. The
comparison command sets the logical result bit according to the result of the comparison. If the
logical result is True, the execution of the instruction list will jump to the command with the
specified index.

26.4. Workflow of the Instruction


The instruction has the following workflow:
1. Check the logical result bit
a. If True, jump to the instruction with the index specified in parameter 1.
b. If False, end the command without taking any action.

26.5. Possible Errors


Error Message

Explanation and Possible Error Cause

The value of parameter 1 is not a valid Indexnumber. Abort

The value of parameter 1 is not a valid integer


number. The instruction list execution will be
aborted.
The index specified in parameter 1 is not a valid
instruction index of the report template. The
instruction list execution will be aborted.

No instruction with the specified index exists.


Abort

57

27.

Open Report File

27.1. Description
The command Open Report File opens the working copy of the report. The working copy needs to
be opened before values can be written into the report. The following preparations must be done
before writing data into a report file:
- Create a new report working copy (Instruction Create New Report File).
- Open the working copy using this instruction.

27.2. Parameters
None

27.3. Sample Application


Open Report File ()
A batch report shows each finished batch data. The batch program starts the report creation by a
command line call. The instruction list executes the following steps:
- Create a new working copy of the report (Instruction Create New Report File).
- Open the working copy using this command (Instruction Open Report File).
- Write data into the report (e.g. by using Read Archived Variable).
- Save the report as PDF (Instruction Save Report as PDF).
- Print the report (Instruction Print Report).
- Move the report to the final output directory (Instruction Save Final Report File).

27.4. Workflow of the Instruction


The instruction has the following workflow:
1. Get the output directory from the report settings.
2. Reset the file property Read Only.
3. Open the report using Excel.

27.5. Possible Errors


Error Message

Explanation and Possible Error Cause

Excel is currently in use. Check if another


scheduling event is using Excel

The working copy is already opened. Check if


multiple scheduling events are trying to open
the file at the same time.
The report setting Output Directory is not
defined correctly.
An error occurred while opening the report file.
Make sure that a new working copy was created
before trying to open it.

The setting 'OutputDirectory' is not accessible


The working copy of the Report file is not
accessible

58

28.

Print Report

28.1. Description
The command Print Report prints the report on an installed printer. The name of the printer can be
specified by a parameter. If the name of the printer cannot be found, the report will be printed on
the default printer defined in the report file (Excel printer settings). In addition, the name of the
worksheet to be printed can be specified. If no worksheet is specified, the whole workbook will be
printed.
Note!
The command can only be executed if the report file is opened.
Note!
Make sure that in the report definition file the print area of each worksheet to be printed is set
correctly. Consider cleaning the report using the command Clean Report before printing.

28.2. Parameters
The command requires two parameters: The name of the worksheet to be printed and the name of
the printer.
28.2.1. Parameter 1: Worksheet
Parameter 1 defines the name of the worksheet to be printed. This parameter is always required.
Valid values are worksheet names existing in the report file or the placeholder symbol *.
Report
The name of the worksheet to be printed.
In this example, the worksheet Report is being printed.
*
If the placeholder symbol * is passed in parameter 1, the complete workbook will be
printed.
28.2.2. Parameter 2: Printer Name
Parameter 2 defines the name of the printer to be used. This parameter is always required.
Valid values are installed printers or the placeholder symbol *.
My Printer
The name of the printer to be used.
In this example, the report will be printed on the printer My Printer.
*
If the placeholder symbol * is being passed in parameter 2, the report will be printed
on the default printer selected in the printer settings of the report file.

28.3. Sample Application


Print Report (Report, My Printer)
Print Report (*,*)
Print Report (*, My Printer)
Print Report (Report,*)
After completion, a report is to be printed automatically on a specified printer.

59

28.4. Workflow of the Instruction


The instruction has the following workflow:
1. Validate the parameters.
2. Test if the specified worksheet exists.
3. Print the report on the specified printer.

28.5. Possible Errors


Error Message

Explanation and Possible Error Cause

Invalid number of parameters

The number of parameters is invalid. 2


parameters need to be passed.
A sheet with the name passed in parameter 1
was not found in the report file.
An error occurred while reading the printer
name. Further error details can be found in the
message list.
An error occurred while printing the report.
Further error details can be found in the
message list.

The specified sheet is not defined in the report


file
Error reading the parameter printer name

Error printing the Report

60

29.

Publish Range

29.1. Description
The command Publish Range exports a specified Excel worksheet area (Excel Range) as image file.
The image can subsequently be used to be displayed e.g. in a SCADA system using a web browser.
Note!
The command can only be executed if the report file is opened.
Note!
The command uses the windows clipboard. Note that clipboard content of other applications will be
overwritten when executing the command.

29.2. Parameters
The instruction requires 4 parameters: The name of the worksheet, the start cell, the end cell and the
destination path and filename.
29.2.1. Parameter 1: Worksheet Name
Parameter 1 specifies the name of the worksheet. Valid values are existing worksheet names. This
parameter is always required.
29.2.2. Parameter 2: Start Cell
Valid values are cell identifiers, e.g. A1. The instruction exports the area between the start and the
end cell.
29.2.3. Parameter 3: End Cell
Valid values are cell identifiers, e.g. J33. The instruction exports the area between the start and the
end cell.
29.2.4. Parameter 4: Path and Filename
Parameter 4 specifies the destination path and filename. The parameter must be specified according
to Windows path and file name rules. The extension name is always .png.

29.3. Sample Application


Publish Range (OEE SCADA, A1, J33, S:\SCADADataExchange\OEE.png)
The operator panel of a machine shows the current OEE. The panels web browser displays a local
website containing the exported image. The image is periodically updated using the instruction
Publish Range.

29.4. Workflow of the Instruction


The instruction has the following workflow:
1. Check if the report file is open
2. Export the specified range as image.

61

29.5. Possible Errors


Error Message

Explanation and Possible Error Cause

The working copy is not opened

To save the reports as PDF, the report file must


be opened first
A worksheet with the name specified in
parameter 1 is not defined in the report file
The range specified in parameter 2 and 3 is
invalid
An error occurred while saving the file. Further
details can be found in the message list

The specified sheet is not defined in the report


file
The specified range is not valid
Error saving the file

62

30.

Read Archived Variable

30.1. Description
The command Read Archived Variable reads values of a specified time range from an archive and
writes them into the defined Excel cells.
Note!
The command can only be executed if the report file is opened.

30.2. Parameters
The instruction requires up to 4 parameters: The name of the archive to read data from, the
beginning and ending of the time range and a flag indicating if a new row should be inserted into the
Excel sheet for each value.
30.2.1. Parameter 1: Archive Name
Parameter 1 specifies the name of the archive to read data from. This parameter is always required.
Valid values are names of archives defined in the report template.
30.2.2. Parameter 2: Start Time or Special Time Range
Parameter 2 can either specify the start time of the time range or a special time range, e.g. This
Day. This parameter is always required.
Valid values are:
- 12/22/2007 2:20:04PM Beginning of the time range
- Last But One Change Values from the last but one change of the archive value*
- Last Change
Values from the last change of the archive value*
- Time Range
Values from a time range defined by the user**
- x Seconds
Values of the last x seconds before starting the command
- x Minutes
Values of the last x minutes before starting the command
- This Minute
Values of this minute
- Previous Minute
Values of the previous minute
- x Hours
Values of the last x hours before starting the command
- This Hour
Values of this hour
- Previous Hour
Values of the previous hour
- x Days
Values of the last x days before starting the command
- This Day
Values of this day
- Previous Day
Values of the previous day
- x Weeks
Values of the last x weeks before starting the command
- This Week
Values of this week
- Previous Week
Values of the previous week
- x Months
Values of the last x months before starting the command
- This Month
Values of this month
- Previous Month
Values of the previous month
- x Years
Values of the last x years before starting the command
- This Year
Values of this year
- Previous Year
Values of the previous year
* To use the special time ranges Last But One Change and Last Change the instruction Get
Change Data must be called before.
** To use a time range selected by the user the instruction User Input must be first called.
63

30.2.3. Parameter 3: End Time or Insert Cells


Depending on the use of parameter 2 (Start time or special time range), parameter 3 specifies either
the end of the time range or the optional flag Insert Rows.
Valid values are:
12/22/2007 2:30:00PM
End of the time range
- Insert Rows
Optional Parameter: For each value a row will be inserted
into Excel
30.2.4. Parameter 4: Insert Rows
If parameters 2 and 3 define the start and end of a time range, parameter 4 can optionally be used to
specify the insertion of rows for each value written into the Excel sheet.
Valid values are:
- Insert Rows
Optional parameter: For each value a row will be inserted into Excel

30.3. Sample Application


Read Archived Variable (Archive1, 1/1/2010 0:00:00, 12/31/2010 11:59:59 PM)
Read Archived Variable (Archive1, 1/1/2010 0:00:00, 12/31/2010 11:59:59 PM, Insert Rows)
Read Archived Variable (Archive1, Last But One Change, Last Change)
Read Archived Variable (Archive1, Last But One Change, Last Change, Insert Rows)
Read Archived Variable (Archive1, 10 Minutes)
Read Archived Variable (Archive1, 10 Minutes, Insert Rows)
Read Archived Variable (Archive1, This Month)
Read Archived Variable (Archive1, This Month, Insert Rows)
A daily report shows the trend curve of a temperature measurement. A scheduling event calls the
command Archive Variable once per minute, which reads the temperature measurement value
from the PLC and writes it into an archive.
Every day at 11:59:59 PM another trigger initiates reading all values of the day from the archive and
writing them into a report sheet by calling the instruction Read Archived Variable (Archive X, This
Day).

30.4. Workflow of the Instruction


The instruction has the following workflow:
1. Parse and check the parameters
2. Read the values of the specified time range from the archive
3. If desired, insert one row for each value into the report sheet
4. Write the values into the report sheet

64

30.5. Possible Errors


Error Message

Explanation and Possible Error Cause

The value of parameter 4 is invalid

A value was specified for parameter 4 but could


not be parsed correctly.
An error occurred while parsing the parameters.
Further details can be found in the message list.
There was no archive definition with the
specified archive name found.
Parameter 2 is neither a valid date and time nor
a special time range keyword. Check the format
and your regional settings.
Before using special time ranges, the change
data must be read from the specified archive.

Invalid Parameters
No Archive named xxx defined
Parameter 2 (From): The parameter cannot be
converted into a valid timespan
Parameter From: The value
'LastButOneValueChangedDateTime' is not
available. Get value by 'GetChangeData'
instruction first
Parameter Until: The value
'LastValueChangedDateTime' is not available.
Get value by 'GetChangeData' instruction first
Parameter From is later than Parameter Until
Error opening the archive
Reading data from the selected time period
results in more than xxx values

Error formatting the value


Error transferring the values

Error writing into the report cell

Before using special time ranges, the change


data must be read from the specified archive.
Error in the time range parameters. Parameter
From is later than Parameter Until.
An error occurred while opening the archive.
Further details can be found in the message list.
In the settings of the report template, the
maximum number of values to be read from an
archive is specified. The actual read request
returned more than this number of values.
An error occurred while formatting the value.
Further details can be found in the message list.
An error occurred while transferring the value to
Excel. Further details can be found in the
message list.
An error occurred while writing into the Excel
cell. Further details can be found in the message
list.

65

31.

Read Batch Index Data

31.1. Description
The instruction Read Batch Index Data reads the begin and the end timestamp from a batch index
archive and provides the data for use in following instructions.

31.2. Parameters
The command requires 3 parameters: The name of the batch index archive, the ID of a variable
containing the Batch ID to search for and a flag indicating if an error message is created if the desired
batch ID was not found in the archive.
31.2.1. Parameter 1: Archive Name
Parameter 1 specifies the name of the batch index archive to read data from. This parameter is
always required. Valid values are names of archives defined in the report template.
31.2.2. Parameter 2: Index of a Variable Containing the Requested Batch ID
This parameter is always required. Valid values are:
- Index of a variable
The index of a variable containing the Batch ID to search for
- User Input
Use of the previously entered Batch ID
(Entered by means of the command User Input)
31.2.3. Parameter 3: Error Message if the Batch ID Was Not Found in the Archive
Valid values are:
- Yes
If the Batch ID was not found in the archive, an error message is
created
- No
No error message is created if the Batch ID was not found in the
Archive

31.3. Sample Application


Read Batch Index Data (BatchIDArchive1, 1, No)
Read Batch Index Data (BatchIDArchive1, User Input, Yes)
A batch report shows for each batch, running on a reactor, the corresponding measurement values
and equipment states, such as temperatures, pH values, conductivities, levels, valve positions, motor
feedbacks or recipe data.
After the command Archive Batch Index was used to archive the Batch ID, the start and the end
timestamp of each batch, this data can be read from the archive using the command Read Batch
Index Data. By this, all values archived during a certain batch was running can be retrieved and
written into a report.

31.4. Workflow of the Instruction


The instruction has the following workflow:
1. Read the Batch ID variable (Parameter 2) from the PLC or read the last user input data
2. Search the archive specified in parameter 1 for corresponding index data
3. Read the start and the end timestamp of the index entry and provide the information for the
following instructions
4. Create an error message if the Batch ID was not found in the archive and Parameter 3 is
Yes
66

31.5. Possible Errors


Error Message

Explanation and Possible Error Cause

There is no archive named xxx defined

There was no archive definition with the name


specified in parameter 1 found.
The value of parameter 2 is not an integer
number.
There was no variable definition with the
specified index found.
Error while reading the variable value from the
PLC. Depending on the error type, additional
information will be shown.
The value of parameter must either be Yes or
No
Error converting the constant specified in
Parameter 3 into the data type of the Batch ID
variable
An error occurred while opening the archive.
Check the archive definition and the archives
database files as well as the access rights to the
storage paths.
The desired Batch was not found in the archive
Data error. Please check if the archive file was
damaged
Data error. Please check if the archive file was
damaged
Data error. Please check if the archive file was
damaged

Invalid Batch ID Variable Index: xxx


There is no variable with index xxx defined
Error reading the Batch ID from the PLC

Invalid value in parameter 3


Error parsing the inactive value

Error opening the archive

The given Batch ID was not found in the archive


Error reading the index data
Error testing for Batch-Finished
Error saving the previous online value

67

32.

Read Indexed Variable

32.1. Description
The same as the command Read Variable, the command Read Indexed Variable reads the online
value of a variable from the PLC and writes it into the cell specified in the variable definition. The
difference to the command Read Variable is that the index of the variable to read is not fixed, but
defined by the value of another variable, the so-called index variable.
Example:
Read Indexed Variable (10)
This command interprets the value of variable 10 as an index - e.g. 17 - and then reads the online
value of the variable with index 17 from the PLC and writes its value to the report.
In contrast to the use of archives, the command Read Indexed Variable writes the variable value
directly to the specified report cell. If specified in the variable definition, the time stamp can also be
written to a report cell.
Note!
The command can only be executed if the report file is opened.

32.2. Parameters
The command requires one parameter: The index of the variable defining the variable to read (Index
variable).
32.2.1. Parameter 1: Index of the Index Variable
This parameter specifies the index of the variable whose value is to be interpreted as an index of the
variable to be read. This parameter is always required.
Valid values are indexes of defined variables.

32.3. Sample Application


Read Indexed Variable (10)
The command Read Indexed Variable is used for dynamic reading of variables. The second variable
determines which value is to be read by holding the index of the variable to be read. Highly flexible
and complex reports can be created by using this instruction.

32.4. Workflow of the Instruction


The instruction has the following workflow:
1. Interpret the value of the index variables as index.
2. Read the indexed variable from the PLC.
3. Format the value according to the settings Format and Unit.
4. Write the value to the specified report cell.
5. If desired, write the timestamp of the value to the specified report cell.

68

32.5. Possible Errors


Error Message

Explanation and Possible Error Cause

Invalid index variable index

The variable index specified in parameter 1 is


not an integer.
The index variable has no valid value. Make sure
that the index variable has an actual value
before using the command.
The value of the index variable must be an
integer number.
The value of the index variable is an integer
number but no variable with that index is
defined.
An error occurred while reading the variable
from the PLC. Further details can be found in the
message list.
An error occurred while writing to the report
cell. Further details can be found in the message
list.

The index variable has no valid actual value

Error converting the actual value of the index


variable into a valid Variable-Index
There is no variable with index: xxx defined

Error reading the value from the PLC

Error writing to the report cell

69

33.

Read SQL Access

33.1. Description
The command Read SQL Access sends a SQL query to Microsoft Access and transfers the result data
into PLC Reports variables and optionally directly into a report.
In order to query data dynamically, it is possible to insert placeholder values like time stamps or any
other variable values into the SQL query.
First, the actual values of the specified placeholder variables are determined and inserted into the
SQL query, then a connection to the database is established and the SQL query is sent to the
database and the results are received and transferred into the specified variables and report cells.
Finally, the connection to the database is being closed.
Note!
SQL queries are interpreted at runtime by the database engine. Therefore PLC Reports only
performs a basic syntax validation. If an error occurs while executing the query, the message
received from the database engine along with the completed SQL query including the current
placeholder variable values are recorded in the PLC Reports message list.

33.2. Data Provider


In order to use the command Read SQL Access, the following installation prerequisites must be
fulfilled:
- The Access database engine must be installed on the computer
- The Access data provider Microsoft.ACE.OLEDB.10.0 must be correctly installed and
configured
If necessary, install and configure the missing programs manually.
Note!
The Access data provider is dependent on the Excel / Office installation 32 Bit or 64 Bit.
If Excel / Office is installed in 64 Bit, the Access data provider and PLC Reports must be installed in
64 Bit as well.

70

33.3. Parameters
The command always requires 5 parameters: The variable range in which the SQL query results are
written into, the columns of the database table to read data from, the definition whether or not PLC
Reports shall automatically insert rows into the report, the connection string and the SQL query.
33.3.1. Parameter 1: Variable Range
Parameter 1 specifies the variable range in which the SQL query result data will be written. The
variable range needs to be subsequent. The sequence of the columns, defined in parameter 2 also
defines the sequence in which the resulting values are written into the variable range.
Example:
Parameter 1 specifies the variable range 1-3, parameter 2 defines the database table columns
Value1; Value2; Value3. In this case, the values of column Value1 will be written into variable 1, the
values of column Value2 will be written into variable 2 and the values of column Value3 will be
written into variable 3.
Note!
The data types of the database columns must be compatible with the data types of the variables.
33.3.2. Parameter 2: Columns of the database table
Parameter 2 defines the columns of the database table to read data from. The resulting data is
written into the actual value of the corresponding variable.
The columns are defined using semicolons as separators.
33.3.3. Parameter 3: Insert Rows
Valid values are:
- Insert Rows
For each result data row, one row is inserted into the Excel report.
- No
The result data is written into excel without inserting rows.
33.3.4. Parameter 4: Connection String
Parameter 4 specifies the database connection string. Make sure that the syntax matches the Access
connection string syntax. Further information about connection strings can be found in the Microsoft
Access documentation.
Note!
Connection strings might contain commas but PLC Reports as well uses commas as parameter
separators. Therefore, connection strings must be enclosed by quotes.

71

33.3.5. Parameter 5: SQL Query


Parameter 5 specifies the SQL query. Further information about the SQL query syntax can be found in
the Microsoft Access documentation.
Variable placeholders are used to dynamically query date, time or value ranges at the moment the
query is executed.
Placeholders are defined in the following format: {#105#}. This example shows a variable placeholder
for variable 105. In addition, make sure to follow the syntax rules for passing values to Access. In
most cases, values can be passed as text. In this case, the values must be enclosed by apostrophes:
{#105#}
When passing date and time values, a special Access syntax must be followed: Such values must be
additionally enclosed by hashes.
Example of a query using a timestamp placeholder variable:
"SELECT * FROM [TableName] WHERE [TimeStampColumnName] >#{#105#}#"
Note!
SQL queries might contain commas but PLC Reports as well uses commas as parameter separators.
Therefore, SQL queries must be enclosed by quotes.
Note!
To avoid interferences with SQL key words, it is recommend to enclose table and column names in
square brackets.

33.4. Sample Application


"ReadSQLAccess (
1-3,
MyColumn1; MyColumn2; MyColumn3,
Insert Rows,
Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Archiv00.accdb; Persist Security Info=False;,
"SELECT * FROM [MyTable] WHERE [TimeStamp] > #{#105#}#")
The command ReadSQLAccess is used to read data from Access databases.

33.5. Workflow of the Instruction


The instruction has the following workflow:
1. Replace the variable placeholders with the actual variable online values
2. Establish a connection to the Access database
3. Send the SQL query
4. Transfer the query results into the actual values of the destination variables
5. Close the connection to the Access database

72

33.6. Possible Errors


Error Message

Explanation and Possible Error Cause

Connection string not found. Please make sure


that quotation marks are being used

The connection string specified in Parameter 4


couldnt be interpreted. Parameter 4 must be
enclosed by quotation marks since it can contain
commas.
The SQL command specified in Parameter 5
couldnt be interpreted. Parameter 5 must be
enclosed by quotation marks since it can contain
commas.
The parameters are invalid.
The index xxx is an integer number but no
variable with that index is defined.
An error occurred while reading the variable
from the PLC. Further details can be found in the
message list.
An error occurred while replacing the variable
placeholder values. Further details can be found
in the message list.
The specified index or index range is invalid.
The number of variables and the number of
columns must be equal.
Syntax error in parameter 2
Parameter 2 specifies a column name which is
not existing in the query result.
The value of the query result couldnt be
converted into the format of the destination
variable.
The query returned more than the maximum
number of data rows, specified in the report
settings.
An error occurred while executing the SQL
query. Further details can be found in the
message list.
An error occurred while connecting to the
server. Further details can be found in the
message list.
An error occurred while writing to the report
cell. Further details can be found in the message
list.

SQL Command not found. Please make sure that


quotation marks are being used

Invalid Parameters
There is no variable with index: xxx defined
Error reading the value from the PLC

Error while replacing variable placeholder values

Invalid variable index or index range: xxx


The number of columns does not match the
number of variables
Error parsing Parameter 2
The specified value column does not exist in the
servers response: xxx
Error formatting the value: xxx

Reading data results in more than xxx values.


Reading the values will be aborted
Error executing the SQL command

Error connecting to the server

Error writing into the report cell

73

74

34.

Read SQL CSV

34.1. Description
The command Read SQL CSV reads data from a csv file using a SQL Odbc data provider and
transfers the result data into PLC Reports variables and optionally directly into a report.
In order to query data dynamically, it is possible to insert placeholder values like time stamps or any
other variable values into the SQL query.
First, the actual values of the specified placeholder variables are determined and inserted into the
SQL query, then the query is sent to the data provider and the results are received and transferred
into the specified variables and report cells. Finally, the connection to the data provider is being
closed.
Note!
SQL queries are interpreted at runtime by the data provide. Therefore PLC Reports only performs a
basic syntax validation. If an error occurs while executing the query, the message received from the
data provider along with the completed SQL query including the current placeholder variable values
are recorded in the PLC Reports message list.

34.2. Data Provider


In order to use the command Read SQL CSV, the following installation prerequisites must be
fulfilled:
- The Odbc text data provider Microsoft Text Driver (*.txt; *.csv) must be installed on the
computer and correctly be configured
- The Microsoft Text Driver (*.txt; *.csv) is currently available as 32 bit version only.
If necessary, install and configure the missing components manually.
Note!
The data provider Microsoft Text Driver (*.txt; *.csv) is currently supported in the 32 bit version
only.

34.3. Schema.ini File


At some regional language settings, the csv field separator is not Comma but another character like
Semicolon. In order to make sure that the csv file is correctly interpreted, a so called Schema.ini
file must be present in the same directory where the csv file is being saved. The minimum content of
the Schema.ini file is the specification of the filed separator. Optionally, the data type of each column
can be specified.
Example content of a Schema.ini file:
[Archiv1.csv]
Format=Delimited(,)
ColNameHeader=True
CharacterSet=ANSI
Further information about Schema.ini files can be found in the official csv file format specifications.

75

34.4. Parameters
The command always requires 5 parameters: The variable range in which the SQL query results are
written into, the columns of the csv file to read data from, the definition whether or not PLC
Reports shall automatically insert rows into the report, the connection string and the SQL query.
34.4.1. Parameter 1: Variable Range
Parameter 1 specifies the variable range in which the SQL query result data will be written. The
variable range needs to be subsequent. The sequence of the columns, defined in parameter 2 also
defines the sequence in which the resulting values are written into the variable range.
Example:
Parameter 1 specifies the variable range 1-3, parameter 2 defines the columns Value1; Value2;
Value3. In this case, the values of column Value1 will be written into variable 1, the values of
column Value2 will be written into variable 2 and the values of column Value3 will be written
into variable 3.
Note!
The data types of the csv file columns must be compatible with the data types of the variables (see
Schema.ini file)
34.4.2. Parameter 2: Columns of the database table
Parameter 2 defines the columns of the csv file to read data from. The resulting data is written into
the actual value of the corresponding variable.
The columns are defined using semicolons as separators.
34.4.3. Parameter 3: Insert Rows
Valid values are:
- Insert Rows
For each result data row, one row is inserted into the Excel report.
- No
The result data is written into excel without inserting rows.
34.4.4. Parameter 4: Connection String
Parameter 4 specifies the database connection string. Make sure that the syntax matches the
connection string syntax of the data provider. Further information about connection strings can be
found in the Microsoft Microsoft Text Driver (*.txt; *.csv) documentation.
Note!
Connection strings might contain commas but PLC Reports as well uses commas as parameter
separators. Therefore, connection strings must be enclosed by quotes.

76

34.4.5. Parameter 5: SQL Query


Parameter 5 specifies the SQL query. Further information about the SQL query syntax can be found in
the official SQL syntax documentation.
Variable placeholders are used to dynamically query date, time or value ranges at the moment the
query is executed.
Placeholders are defined in the following format: {#105#}. This example shows a variable placeholder
for variable 105. In addition, make sure to follow the syntax rules for passing values to the data
provider. In most cases, values can be passed as text. In this case, the values must be enclosed by
apostrophes: {#105#}
Example of a SQL query containing a time stamp placeholder variable:
"SELECT * FROM Filename.csv WHERE [TimestampColumnName] >{#105#}"
Note!
SQL queries might contain commas but PLC Reports as well uses commas as parameter separators.
Therefore, SQL queries must be enclosed by quotes.
Note!
To avoid interferences with SQL key words, it is recommend to enclose table and column names in
square brackets.

34.5. Sample Application


"ReadSQLCSV (
1-3,
MyColumn1; MyColumn2; MyColumn3,
Insert Rows,
"Driver={Microsoft Text Driver (*.txt; *.csv)};DBQ=C:\CSVData\;Extensions=csv,txt",
"SELECT * FROM CSVFileName.csv WHERE [TimestampColumnName] > '{#105#}' ORDER BY
[TimestampColumnName] DESC")
The command ReadSQLCSV is used to read data from csv data files.

34.6. Workflow of the Instruction


The instruction has the following workflow:
1. Replace the variable placeholders with the actual variable online values
2. Establish a connection to the specified csv file
3. Send the SQL query
4. Transfer the query results into the actual values of the destination variables
5. Close the connection to the csv file

77

34.7. Possible Errors


Error Message

Explanation and Possible Error Cause

Connection string not found. Please make sure


that quotation marks are being used

The connection string specified in Parameter 4


couldnt be interpreted. Parameter 4 must be
enclosed by quotation marks since it can contain
commas.
The SQL command specified in Parameter 5
couldnt be interpreted. Parameter 5 must be
enclosed by quotation marks since it can contain
commas.
The parameters are invalid.
The index xxx is an integer number but no
variable with that index is defined.
An error occurred while reading the variable
from the PLC. Further details can be found in the
message list.
An error occurred while replacing the variable
placeholder values. Further details can be found
in the message list.
The specified index or index range is invalid.
The number of variables and the number of
columns must be equal.
Syntax error in parameter 2
Parameter 2 specifies a column name which is
not existing in the query result.
The value of the query result couldnt be
converted into the format of the destination
variable.
The query returned more than the maximum
number of data rows, specified in the report
settings.
An error occurred while executing the SQL
query. Further details can be found in the
message list.
An error occurred while connecting to the data
provider. Further details can be found in the
message list.
An error occurred while writing to the report
cell. Further details can be found in the message
list.

SQL Command not found. Please make sure that


quotation marks are being used

Invalid Parameters
There is no variable with index: xxx defined
Error reading the value from the PLC

Error while replacing variable placeholder values

Invalid variable index or index range: xxx


The number of columns does not match the
number of variables
Error parsing Parameter 2
The specified value column does not exist in the
servers response: xxx
Error formatting the value: xxx

Reading data results in more than xxx values.


Reading the values will be aborted
Error executing the SQL command

Error connecting to the server

Error writing into the report cell

78

35.

Read SQL Server

35.1. Description
The command Read SQL Server sends a SQL query to the specified SQL Server and transfers the
result data into PLC Reports variables and optionally directly into a report.
In order to query data dynamically, it is possible to insert placeholder values like time stamps or any
other variable values into the SQL query.
First, the actual values of the specified placeholder variables are determined and inserted into the
SQL query, then a connection to the database is established and the SQL query is sent to the
database server and the results are received and transferred into the specified variables and report
cells. Finally, the connection to the database server is being closed.
Note!
SQL queries are interpreted at runtime by the database engine. Therefore PLC Reports only
performs a basic syntax validation. If an error occurs while executing the query, the message
received from the database engine along with the completed SQL query including the current
placeholder variable values are recorded in the PLC Reports message list.

35.2. Parameters
The command always requires 5 parameters: The variable range in which the SQL query results are
written into, the columns of the database table to read data from, the definition whether or not PLC
Reports shall automatically insert rows into the report, the connection string and the SQL query.
35.2.1. Parameter 1: Variable Range
Parameter 1 specifies the variable range in which the SQL query result data will be written. The
variable range needs to be subsequent. The sequence of the columns, defined in parameter 2 also
defines the sequence in which the resulting values are written into the variable range.
Example:
Parameter 1 specifies the variable range 1-3, parameter 2 defines the database table columns
Value1; Value2; Value3. In this case, the values of column Value1 will be written into variable 1, the
values of column Value2 will be written into variable 2 and the values of column Value3 will be
written into variable 3.
Note!
The data types of the database columns must be compatible with the data types of the variables.
35.2.2. Parameter 2: Columns of the database table
Parameter 2 defines the columns of the database table to read data from. The resulting data is
written into the actual value of the corresponding variable.
The columns are defined using semicolons as separators.

79

35.2.3. Parameter 3: Insert Rows


Valid values are:
- Insert Rows
For each result data row, one row is inserted into the Excel report.
- No
The result data is written into excel without inserting rows.
35.2.4. Parameter 4: Connection String
Parameter 4 specifies the database connection string. Make sure that the syntax matches the SQL
Server connection string syntax. Further information about connection strings can be found in the
Microsoft SQL Server documentation.
Note!
Connection strings might contain commas but PLC Reports as well uses commas as parameter
separators. Therefore, connection strings must be enclosed by quotes.
35.2.5. Parameter 5: SQL Query
Parameter 5 specifies the SQL query. Further information about the SQL query syntax can be found in
the Microsoft SQL Server documentation.
Variable placeholders are used to dynamically query date, time or value ranges at the moment the
query is executed.
Placeholders are defined in the following format: {#105#}. This example shows a variable placeholder
for variable 105. In addition, make sure to follow the syntax rules for passing values to the SQL
Server. In most cases, values can be passed as text. In this case, the values must be enclosed by
apostrophes: {#105#}
Note!
SQL queries might contain commas but PLC Reports as well uses commas as parameter separators.
Therefore, SQL queries must be enclosed by quotes.
Note!
To avoid interferences with SQL key words, it is recommend to enclose table and column names in
square brackets.

35.3. Sample Application


"ReadSQLServer (
1-3,
MyColumn1; MyColumn2; MyColumn3,
Insert Rows,
Server=MyServer\MyServerInstance;Database=MyDatenbase;Trusted_Connection=True;",
"SELECT * FROM [MyTable] WHERE [TimeStamp] > '{#105#}'")
The command ReadSQLServer is used to read data from SQL Server databases.

80

35.4. Workflow of the Instruction


The instruction has the following workflow:
6. Replace the variable placeholders with the actual variable online values
7. Establish a connection to the SQL Server database
8. Send the SQL query
9. Transfer the query results into the actual values of the destination variables
10. Close the connection to the SQL Server database

81

35.5. Possible Errors


Error Message

Explanation and Possible Error Cause

Connection string not found. Please make sure


that quotation marks are being used

The connection string specified in Parameter 4


couldnt be interpreted. Parameter 4 must be
enclosed by quotation marks since it can contain
commas.
The SQL command specified in Parameter 5
couldnt be interpreted. Parameter 5 must be
enclosed by quotation marks since it can contain
commas.
The parameters are invalid.
The index xxx is an integer number but no
variable with that index is defined.
An error occurred while reading the variable
from the PLC. Further details can be found in the
message list.
An error occurred while replacing the variable
placeholder values. Further details can be found
in the message list.
The specified index or index range is invalid.
The number of variables and the number of
columns must be equal.
Syntax error in parameter 2
Parameter 2 specifies a column name which is
not existing in the query result.
The value of the query result couldnt be
converted into the format of the destination
variable.
The query returned more than the maximum
number of data rows, specified in the report
settings.
An error occurred while executing the SQL
query. Further details can be found in the
message list.
An error occurred while connecting to the
server. Further details can be found in the
message list.
An error occurred while writing to the report
cell. Further details can be found in the message
list.

SQL Command not found. Please make sure that


quotation marks are being used

Invalid Parameters
There is no variable with index: xxx defined
Error reading the value from the PLC

Error while replacing variable placeholder values

Invalid variable index or index range: xxx


The number of columns does not match the
number of variables
Error parsing Parameter 2
The specified value column does not exist in the
servers response: xxx
Error formatting the value: xxx

Reading data results in more than xxx values.


Reading the values will be aborted
Error executing the SQL command

Error connecting to the server

Error writing into the report cell

82

36.

Read Variable

36.1. Description
The command Read Variable reads the online value of a variable from the PLC and writes it into the
cell specified in the variable definition. In contrast to the use of archives, the command Read
Indexed Variable writes the variable value directly to the specified report cell. If specified in the
variable definition, the time stamp can also be written to a report cell.
If the variable definition does not define a report sheet and cell, the value is being read from the PLC
without writing it into a report cell. After executing the instruction, the value of the variable is
available for use in the following instructions.

36.2. Parameters
The command requires two parameter: The index of the variable to be read and optionally a flag
indicating if a new row should be inserted into the Excel sheet for each value.
36.2.1. Parameter 1: Index of the Variable
This parameter specifies the index of the variable to be read. This parameter is always required.
Valid values are indexes of defined variables.
36.2.2. Parameter 2: Insert Rows
Parameter 2 can optionally be used to specify the insertion of rows for each value written into the
Excel sheet.
Valid values are:
- Insert Rows
Optional parameter: For each value a row will be inserted into Excel

36.3. Sample Application


Read Variable (1)
Read Variable (1, Insert Rows)
The command Read Variable is used if a value of a variable has to be written directly to a report,
without the use of archives.

36.4. Workflow of the Instruction


The instruction has the following workflow:
1. Read the variable from the PLC.
2. Format the value according to the settings Format and Unit.
3. Write the value to the specified report cell.
4. If desired, write the timestamp of the value to the specified report cell.

83

36.5. Possible Errors


Error Message

Explanation and Possible Error Cause

Invalid variable index

The variable index specified in parameter 1 is


not an integer.
The index specified in parameter 1 is an integer
number but no variable with that index is
defined.
An error occurred while reading the variable
from the PLC. Further details can be found in the
message list.
An error occurred while writing to the report
cell. Further details can be found in the message
list.

There is no variable with index: xxx defined

Error reading the value from the PLC

Error writing to the report cell

84

37.

Read Variable from Cell

37.1. Description
The command Read Variable from Cell reads the value from the Excel cell defined in the variable
definition and uses it as the online value of the variable. The command can be used to perform Excel
formula or macro based calculations and then to write the result back into a variable. The timestamp
of the variable will be set to the reading time of the value from the cell.
Note!
The command can only be executed if the report file is opened.

37.2. Parameters
The command requires one parameter: The index of the variable to be read.
37.2.1. Parameter 1: Index of the Variable
This parameter specifies the index of the variable to be read from the Excel cell. This parameter is
always required.
Valid values are indexes of defined variables.

37.3. Sample Application


Read Variable from Cell (1)
The command can be used to perform Excel formula or macro based calculations and then to write
the result back into a variable.

37.4. Workflow of the Instruction


The instruction has the following workflow:
1. Read the value from the Excel cell.
2. Set the timestamp of the variable value to the reading time of the value from Excel.
3. Use the read value as online value of the variable.

37.5. Possible Errors


Error Message

Explanation and Possible Error Cause

Invalid variable index

The variable index specified in parameter 1 is


not an integer.
The index specified in parameter 1 is an integer
number but no variable with that index is
defined.
An error occurred while reading the variable
from the report cell. Further details can be found
in the message list.

There is no variable with index: xxx defined

Error reading the value from the report cell

85

38.

Read Variable Range

38.1. Description
The command Read Variable Range reads the online value of multiple variables from the PLC and
writes them into the cells specified in the variable definitions. In contrast to the use of archives, the
command Read Variable Range writes the variable values directly to the specified report cells. If
specified in the variable definitions, the time stamps can also be written to the report cells.
If the variable definition does not define a report sheet and cell, the value is being read from the PLC
without writing it into a report cell. After executing the instruction, the value of the variable is
available for use in the following instructions.

38.2. Parameters
The command requires one parameter: The index range of the variables to be read.
38.2.1. Parameter 1: Index Range
This parameter specifies the index range of the variables to be read. This parameter is always
required.
Valid values are indexes of defined variables. The index range is specified in the following format:
Start index - end index
Example: 1-10

38.3. Sample Application


Read Variable Range (1-10)
The command Read Variable Range is used if multiple variables have to be written directly to a
report, without the use of archives.

38.4. Workflow of the Instruction


The instruction has the following workflow:
1. Read the variables from the PLC.
2. Format the values according to the settings Format and Unit.
3. Write the values to the specified report cells.
4. If desired, write the timestamps of the values to the specified report cells.

38.5. Possible Errors


Error Message

Explanation and Possible Error Cause

Invalid variable index range

The index range in parameter 1 has no valid


format.
The index specified in parameter 1 is an integer
number but no variable with that index is
defined.
An error occurred while reading the variable
from the PLC. Further details can be found in the
message list.
An error occurred while writing to the report
cell. Further details can be found in the message
list.

There is no variable with index: xxx defined

Error reading the value from the PLC

Error writing to the report cell

86

39.

Run Macro

39.1. Description
The command Run Macro calls an Excel macro defined in the report file.
Note!
The command can only be executed if the report file is opened.
Note!
To run macros correctly without showing the Excel inquiry dialogs, the following points must be
considered when saving the report template:
- The report template must be saved in the .xlsm file format.
- The report file must be saved in an Excel trusted location.
- The report template must be saved without the option to Remove personal information
from file properties on save:

39.2. Parameters
The command requires one parameter: The name of the macro to be called.
39.2.1. Parameter 1: Macro Name
Parameter 1 specifies the name of the macro to be called. Valid values are names of macros defined
in the report template file.

39.3. Sample Application


Run Macro (Macro1)
The command Run Macro is used if the functional scope of a report needs to be extended by
running your own Excel macros.
87

39.4. Workflow of the Instruction


The instruction has the following workflow:
1. Run the macro specified in parameter 1.

39.5. Possible Errors


Error Message

Explanation and Possible Error Cause

Running macros is not licensed

The installed license of PLC Report is not valid


for running macros. Install an upgrade license to
run macros.
The command can only be executed if the report
file was opened before.
An error occurred while executing the macro.
Further error details can be found in the
message list.

The working copy is not opened


Error executing the macro

88

40.

Save Final Report File

40.1. Description
The command Save Final Report File saves and closes the current working copy of the report,
creates the final filename and moves it to the final output directory. Depending on the report
settings, subfolders for years, months, weeks or days are created. The final report filename is the
combination of the template name and the actual date and time in format JJJJ-MM-TT SS.MM.SS.
This format is used independently of the regional settings to make sure that the reports are ordered
by date, if shown in the Windows Explorer. As time separator, instead of :, . is used because the
use of : is not allowed in Windows filenames.

40.2. Parameters
Optionally, a user defined filename can be used
40.2.1. Parameter 1: User Defined File Name
Parameter 1 optionally specifies the format of the report file name. Strings as well as variable values
can be used. The slash character / is used as separator.
String
Any string, enclosed by quotation marks.
30
The index of a variable. The value of the variable is used in the file name.

40.3. Sample Application


Save Final Report File ()
Save Final Report File (Batch Report "/30/" - "/101/" - "/100)
A report shows trend data of the week and is printed at the end of the week (Instruction Print
Report) and then moved to the final output directory using the command Save Final Report File.
The final output directory will be the combination of the output directory and a subfolder for the
year because in this example the report settings specify that for each year a subfolder is to be
created.
The second example shows the definition of a user defined filename. In the example, variable 30
contains the current Batch-ID, variable 101 the system variable Report Name and variable 100 the
system variable Report Start.

40.4. Workflow of the Instruction


The instruction has the following workflow:
1. Save the report file if it is opened.
2. Close the report file if it is opened.
3. Check if a working copy exists in the output directory.
a. Abort with an error message if no report working copy exists.
4. Create subfolders according to the report settings.
5. Create the final filename by removing Working and adding the timestamp to the report
name.
6. Move the working copy with the new file name to the final destination.
7. Set the report file to Read Only.

89

40.5. Possible Errors


Error Message

Explanation and Possible Error Cause

Error saving the report file

An error occurred while saving the report file.


Further detail can be found in the message list.
The report setting Output Directory is not
defined correctly.
At least one of the settings Create Daily
Subfolder, Create Weekly Subfolder, Create
Monthly Subfolder or Create Annual
Subfolder is not defined in the report template.
An error occurred while creating the final file
name. The maximum number of equally named
report files is reached. Check your trigger
settings.
The operating system did not allow moving of
the file within the timeout time. Make sure that
no other programs access the report file.
Particularly check your virus scanner settings
and actions.
An error occurred while setting the final report
file to Read Only. Further details can be found
in the message list.
An error occurred while moving the report file to
the final output directory. Further detail can be
found in the message list.
No working copy was found in the output
directory.

The setting 'OutputDirectory' is not accessible


The settings 'CreateXXXSubfolder' are not
available.

Error creating the final filename

Waited 5 times for moving the working file, but


the operating system did not finalize the action

Error setting the final report file to ReadOnly

Error moving the working copy to the final


destination
No working copy exists in working directory

90

41.

Save Report as PDF

41.1. Description
The command Save Report as PDF saves the actual working copy of the report as PDF into the final
output directory. The worksheet to be saved as PDF can be specified in the parameters. If no
worksheet is specified, the complete workbook is saved as PDF.
Depending on the report settings, subfolders for years, months, weeks or days are created. The final
report filename is the combination of the template name and the actual date and time in format JJJJMM-TT SS.MM.SS. This format is used independently of the regional settings to make sure that the
reports are ordered by date, if shown in the Windows Explorer. As time separator, instead of :, .
is used because the use of : is not allowed in Windows filenames.
Note!
The command Save Report as PDF is supported in Excel 2007 or newer. If Excel 2003 is being used,
PDF files can only be created using a PDF printer in combination with the command Print Report.

41.2. Parameters
The command requires one parameter: The definition of the worksheet to be saved as PDF.
Optionally, a user defined filename can be used
41.2.1. Parameter 1: Worksheet
Report
The name of the worksheet to be saved as PDF.
In this example, the worksheet Report is saved as PDF.
*
If the placeholder * is used, the complete workbook is being saved as PDF.
41.2.2. Parameter 2: User Defined File Name
Parameter 1 optionally specifies the format of the report file name. Strings as well as variable values
can be used. The slash character / is used as separator.
String
Any string, enclosed by quotation marks.
30
The index of a variable. The value of the variable is used in the file name.

41.3. Sample Application


Save Report as PDF (Report)
Save Report as PDF (*)
Save Report as PDF (*, "Batch-Report "/30/" - "/101/" - "/100)
A report is to be saved in PDF format. After the report is finished, a PDF version is created.
The third example shows the definition of a user defined filename. In the example, variable 30
contains the current Batch-ID, variable 101 the system variable Report Name and variable 100 the
system variable Report Start.

91

41.4. Workflow of the Instruction


The instruction has the following workflow:
1. Create subfolders in the final output directory depending on the report settings.
2. Create the final filename.
3. Save the report as PDF with the final filename.

41.5. Possible Errors


Error Message

Explanation and Possible Error Cause

Saving reports as PDF is only supported with


Excel 2007 or newer versions.
The working copy is not opened

An Excel version without the support to save in


PDF format is installed.
To save the reports as PDF, the report file must
be opened first.
The report setting Output Directory is not
defined correctly.
At least one of the settings Create Daily
Subfolder, Create Weekly Subfolder, Create
Monthly Subfolder or Create Annual
Subfolder is not defined in the report template.
An error occurred while creating the output
directory. Further details can be found in the
message list.
An error occurred while creating the final file
name. The maximum number of equally named
report files is reached. Check your trigger
settings.
A worksheet with the name specified in
parameter 1 is not defined in the report file.
An error occurred while saving the report file as
PDF. Further details can be found in the message
list.

The setting 'OutputDirectory' is not accessible


The settings 'CreateXXXSubfolder' are not
available.

Error creating the output directory

Error creating the final filename

The specified sheet is not defined in the report


file
Error saving the Excel file as PDF

92

42.

Save Report File

42.1. Description
The command Save Report File saves the changes of the actual working copy of the report. The
command does not move the file to the final output directory, so that it can be reopened at any time
to add further data. If the report must be saved and moved to the final destination, use the
instruction Save Final Report File instead.

42.2. Parameters
None

42.3. Sample Application


Save Final Report File ()
A weekly report is filled with the data during the week without using archives. On Friday evening at
6:00 PM the report is printed (Instruction Print Report) and saved as PDF (Instruction Save Report
as PDF).
During the week, the command Save Report File is being used so that each day the data can be
added to the same report. The working copy of the report is not moved to the final output directory
until Friday evening.

42.4. Workflow of the Instruction


The instruction has the following workflow:
1. Check if the report file is open. If not, show error message and abort
2. Save the report file.

42.5. Possible Errors


Error Message

Explanation and Possible Error Cause

The working copy is not opened

The instruction was executed but the report is


not opened.
An error occurred while saving the report file.
Further details can be found in the message list.

Error saving the Excel file

93

43.

Send Report As Email

43.1. Description
The command Send Report As Email sends the last saved report file as email to the specified
recipient(s). If the reports was saved before as PDF, the PDF file will be sent, whereas if the report
was saved as Excel, the Excel file will be sent.
To send a report in both formats (PDF and Excel), please proceed as following:
1. Save the report as PDF using the command Save Report As PDF
2. Send the PDF report using the command Send Report As Email
3. Save the report as Excel version using the command Save Final Report File
4. Send the Excel version of the report using the command Send Report As Email
Note!
The command Save Report as PDF is supported in Excel 2007 or newer. If Excel 2003 is being used,
PDF files can only be created using a PDF printer in combination with the command Print Report.

43.2. Parameters
The command requires ten parameters:
43.2.1. Parameter 1: Sender Email Account
Parameter 1 specifies the email account to be used to send the report.
43.2.2. Parameter 2: From
Parameter 2 specifies the sender name. The recipient will see the sender name in the From field.
43.2.3. Parameter 3: Recipient Email Address
Parameter 3 specifies the recipients email address. If the report is sent to multiple recipients, the
email addresses must be specified separated by semicolon.
43.2.4. Parameter 4: Subject
Parameter 4 specifies the subject of the email.
43.2.5. Parameter 5: Message Text
Parameter 5 can be used to define a message text. Note that the message text must not contain
commas since the commas is used as parameter separator.
43.2.6. Parameter 6: Mail Server
Parameter 6 specifies the name of the mail server used to send the email.
43.2.7. Parameter 7: Port
Parameter 7 specifies the mail server port.
43.2.8. Parameter 8: Password
Parameter 8 specifies the mail server password.
43.2.9. Parameter 9: SSL
Parameter 9 specifies whether or not the email is send with SSL encryption.
Valid values are:
- SSL
- No
94

43.2.10.
Parameter 10: Timeout
Parameter 10 specifies the send timeout. Depending on the size of the report and the internet
connection speed, sending the report can take between several seconds up to multiple minutes.
The timeout is specified in milliseconds.

43.3. Sample Application


Send Report As Email (
MySenderEmail@MyCompany.com,
PLC Reports,
Recipient1@web.de; Recipient2@gmx.de,
Energy Consumption Report,
Please find attached the latest monthly energy consumption report,
smtp.gmail.com,
587,
My Password,
SSL,
30000 )
The command is used to send report files to an email recipient.

43.4. Workflow of the Instruction


The instruction has the following workflow:
1. Validate the parameters syntax
2. Create an email message.
3. Attach the latest report to the email message
4. Send the email to the recipient(s)

43.5. Possible Errors


Error Message

Explanation and Possible Error Cause

Error in Parameter 7: Port

The value specified in parameter 7 is not a valid


port
The value specified in parameter 10 is not a valid
number
An error occurred while accessing the latest
report file. Further error details can be found in
the message list.
An error occurred while sending the email.
Further error details can be found in the
message list.

Error in Parameter 10: Timeout


Error accessing the last report file

Error sending the email

95

44.

User Input

44.1. Description
The instruction User Input is designed to let the user manually select a time range when starting a
report manually. It can be called at the start of a manual report for selecting the desired report time
range.

44.2. Parameters
The command requires one parameter which selects the type of the user input Time Range or
BatchID.
44.2.1. Parameter 1: Time Range or Batch ID
This parameter prompts the user to select a time range or a Batch ID. This parameter is always
required.
Valid values are:
- Time Range
- Batch ID

44.3. Sample Application


User Input (Time Range)
User Input (Batch ID)
A daily trend report shows the trend of all measured values for each day. In addition to the
automatically triggered report creation at the end of each day, the user has the option to start the
report manually at any time. Using the command User Input (Time Range), the desired time range
of the manual report can be selected by the user when the report starts. Subsequently, all values
within the selected time range are read from the archive and written into the report by using the
command Read Archived Variable (Archive Name, Time Range).

44.4. Workflow of the Instruction


The instruction has the following workflow:
1. Show a dialog to let the user select a time range or a Batch ID.
2. Provide the selected time range or Batch ID for the subsequent instructions.

44.5. Possible Errors


Error Message

Explanation and Possible Error Cause

Error while manual time range input. Abort

An error occurred while entering the time range.


Further error details can be found in the
message list.
An error occurred while entering the Batch ID.
Further error details can be found in the
message list.
An error occurred while entering the time range.
Further error details can be found in the
message list.
The dialog type defined in parameter 1 is invalid.

Error while Batch ID input. Abort

Error while manual time range input. Abort

Unknown Input Type

96

45.

Write SQL Access

45.1. Description
The command Write SQL Access writes the actual values of the specified variables into a Microsoft
Access database.
First, the actual values of the specified placeholder variables are determined and inserted into the
SQL query, then a connection to the database is established and the SQL command is sent to the
database. Finally, the connection to the database is being closed.
Note!
SQL queries are interpreted at runtime by the database engine. Therefore PLC Reports only
performs a basic syntax validation. If an error occurs while executing the command, the message
received from the database engine along with the completed SQL command including the current
placeholder variable values are recorded in the PLC Reports message list.
Note!
Since Access databases are file based, accessing the same database from multiple reports at the
same time may lead to access violations. Consider using a SQL Server database instead if access from
multiple reports is needed.

45.2. Data Provider


In order to use the command Write SQL Access, the following installation prerequisites must be
fulfilled:
- The Access database engine must be installed on the computer
- The Access data provider Microsoft.ACE.OLEDB.10.0 must be correctly installed and
configured
If necessary, install and configure the missing programs manually.
Note!
The Access data provider is dependent on the Excel / Office installation 32 Bit or 64 Bit.
If Excel / Office is installed in 64 Bit, the Access data provider and PLC Reports must be installed in
64 Bit as well.

45.3. Parameters
The command always requires 2 parameters: The connection string and the SQL command.
45.3.1. Parameter 1: Connection String
Parameter 1 specifies the database connection string. Make sure that the syntax matches the SQL
Access connection string syntax. Further information about connection strings can be found in the
Microsoft Access documentation.
Note!
Connection strings might contain commas but PLC Reports as well uses commas as parameter
separators. Therefore, connection strings must be enclosed by quotes.

97

45.3.2. Parameter 2: SQL Command


Parameter 2 specifies the SQL command. Further information about the SQL command syntax can be
found in the Microsoft Access documentation.
Variable placeholders are used to dynamically insert actual variable values into the SQL command at
the moment the query is executed.
Placeholders are defined in the following format: {#105#}. This example shows a variable placeholder
for variable 105. In addition, make sure to follow the syntax rules for passing values to the Access. In
most cases, values can be passed as text. In this case, the values must be enclosed by apostrophes:
{#105#}
When passing date and time values, a special Access syntax must be followed: Such values must be
additionally enclosed by hashes. Example: #{#105#}#
Note!
SQL commands might contain commas but PLC Reports as well uses commas as parameter
separators. Therefore, SQL commands must be enclosed by quotes.
Note!
To avoid interferences with SQL key words, it is recommend to enclose table and column names in
square brackets.

45.4. Sample Application


WriteSQLAccess (
"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\DATA\DatabaseName.accdb; Persist Security
Info=False;",
"INSERT INTO [MyTable] ([MyColumn1], [MyColumn2], [MyColumn3])
VALUES ('{#1#}', '{#2#}', '{#3#}')")
The command WriteSQLAccess is used to write data into Access databases.

45.5. Workflow of the Instruction


The instruction has the following workflow:
1. Replace the variable placeholders with the actual variable online values
2. Establish a connection to the Access database
3. Send the SQL command
4. Close the connection to the Access database

98

45.6. Possible Errors


Error Message

Explanation and Possible Error Cause

Connection string not found. Please make sure


that quotation marks are being used

The connection string specified in Parameter 1


couldnt be interpreted. Parameter 1 must be
enclosed by quotation marks since it can contain
commas.
The SQL command specified in Parameter 2
couldnt be interpreted. Parameter 2 must be
enclosed by quotation marks since it can contain
commas.
The parameters are invalid.
The index xxx is an integer number but no
variable with that index is defined.
An error occurred while reading the variable
from the PLC. Further details can be found in the
message list.
An error occurred while replacing the variable
placeholder values. Further details can be found
in the message list.
Write requests are queued. The size of the write
buffer can be adjusted separately for each
report using the report settings.
Write requests are queued. An error occurred
while adding the write request to the request
que. Further details can be found in the message
list.
An error occurred while executing the SQL
query. Further details can be found in the
message list.
An error occurred while connecting to the
server. Further details can be found in the
message list.
An error occurred while writing data to the
server. Further details can be found in the
message list.
An error occurred while computing the write
buffer. Further details can be found in the
message list.

SQL Command not found. Please make sure that


quotation marks are being used

Invalid Parameters
There is no variable with index: xxx defined
Error reading the value from the PLC

Error while replacing variable placeholder values

Buffer overflow while adding the value to the


write requests que
Error adding the value to the write requests que

Error executing the SQL command

Error connecting to the server

Error writing data

Error computing the write buffer

99

46.

Write CSV

46.1. Description
The command Write CSV writes the actual values of the specified variables into CSV file.
First, the actual values of the specified placeholder variables are determined, then one row
containing the variables values is being added to the CSV file.
Note!
If the same CSV file is accessed by multiple reports at the same time, access violations can occur.
Consider using a SQL Server database instead if access from multiple reports is needed.

46.2. Parameters
The command always requires 3 parameters: The name and the path of the CSV file, the column
separator and a list of values to be written.
46.2.1. Parameter 1: Name and Path of the CSV File
Parameter 1 specifies the complete name and path of the CSV file.
46.2.2. Parameter 2: Column Separator
Parameter 2 specifies the column separator character.
Valid values are:
- Space
- Comma
- Semicolon
- Tab
46.2.3. Parameter 3-n: List of Variables
Parameter 3-n specifies all variables to be written into the CSV file.

46.3. Sample Application


WriteCSV (
C:\Data\Archiv1.csv, Semicolon,
20,21,22,23,24,25,26,27,28,29,30,31,32,33)
The command WriteCSV is used to write data into CSV data files.

46.4. Workflow of the Instruction


The instruction has the following workflow:
1. Read the variable values from the PLC
2. Write the values into the CSV file

100

46.5. Possible Errors


Error Message

Explanation and Possible Error Cause

Parameter n is not a valid number


There is no variable with index: xxx defined

The specified variable index is not a number


The index xxx is an integer number but no
variable with that index is defined.
An error occurred while reading the variable
from the PLC. Further details can be found in the
message list.
Write requests are queued. The size of the write
buffer can be adjusted separately for each
report using the report settings.
Write requests are queued. An error occurred
while adding the write request to the request
que. Further details can be found in the message
list.
An error occurred while writing data to the file.
Further details can be found in the message list.
An error occurred while computing the write
buffer. Further details can be found in the
message list.

Error reading the value from the PLC

Buffer overflow while adding the value to the


write requests que
Error adding the value to the write requests que

Error writing data


Error computing the write buffer

101

47.

Write SQL Server

47.1. Description
The command Write SQL Server writes the actual values of the specified variables into a SQL Server
database.
First, the actual values of the specified placeholder variables are determined and inserted into the
SQL query, then a connection to the database server is established and the SQL command is sent to
the database server. Finally, the connection to the database server is being closed.
Note!
SQL queries are interpreted at runtime by the database engine. Therefore PLC Reports only
performs a basic syntax validation. If an error occurs while executing the command, the message
received from the database engine along with the completed SQL command including the current
placeholder variable values are recorded in the PLC Reports message list.

47.2. Parameters
The command always requires 2 parameters: The connection string and the SQL command.
47.2.1. Parameter 1: Connection String
Parameter 1 specifies the database connection string. Make sure that the syntax matches the SQL
Server connection string syntax. Further information about connection strings can be found in the
Microsoft SQL Server documentation.
Note!
Connection strings might contain commas but PLC Reports as well uses commas as parameter
separators. Therefore, connection strings must be enclosed by quotes.
47.2.2. Parameter 2: SQL Command
Parameter 2 specifies the SQL command. Further information about the SQL command syntax can be
found in the Microsoft SQL Server documentation.
Variable placeholders are used to dynamically insert actual variable values into the SQL command at
the moment the query is executed.
Placeholders are defined in the following format: {#105#}. This example shows a variable placeholder
for variable 105. In addition, make sure to follow the syntax rules for passing values to the SQL
Server. In most cases, values can be passed as text. In this case, the values must be enclosed by
apostrophes: {#105#}
Note!
SQL queries might contain commas but PLC Reports as well uses commas as parameter separators.
Therefore, SQL queries must be enclosed by quotes.
Note!
To avoid interferences with SQL key words, it is recommend to enclose table and column names in
square brackets.

102

47.3. Sample Application


WriteSQLServer ("Server=MyServerName\MyServerInstance;Database=MyDatenbase;
Trusted_Connection=True;",
"INSERT INTO [MyTable] ([MyColumn1], [MyColumn2], [MyColumn3])
VALUES ('{#1#}', '{#2#}', '{#3#}')")
The command WriteSQLServer is used to write data into SQL Server databases.

47.4. Workflow of the Instruction


The instruction has the following workflow:
3. Replace the variable placeholders with the actual variable online values
4. Establish a connection to the SQL Server database
5. Send the SQL command
6. Close the connection to the SQL Server database

103

47.5. Possible Errors


Error Message

Explanation and Possible Error Cause

Connection string not found. Please make sure


that quotation marks are being used

The connection string specified in Parameter 1


couldnt be interpreted. Parameter 1 must be
enclosed by quotation marks since it can contain
commas.
The SQL command specified in Parameter 2
couldnt be interpreted. Parameter 2 must be
enclosed by quotation marks since it can contain
commas.
The parameters are invalid.
The index xxx is an integer number but no
variable with that index is defined.
An error occurred while reading the variable
from the PLC. Further details can be found in the
message list.
An error occurred while replacing the variable
placeholder values. Further details can be found
in the message list.
Write requests are queued. The size of the write
buffer can be adjusted separately for each
report using the report settings.
Write requests are queued. An error occurred
while adding the write request to the request
que. Further details can be found in the message
list.
An error occurred while executing the SQL
query. Further details can be found in the
message list.
An error occurred while connecting to the
server. Further details can be found in the
message list.
An error occurred while writing data to the
server. Further details can be found in the
message list.
An error occurred while computing the write
buffer. Further details can be found in the
message list.

SQL Command not found. Please make sure that


quotation marks are being used

Invalid Parameters
There is no variable with index: xxx defined
Error reading the value from the PLC

Error while replacing variable placeholder values

Buffer overflow while adding the value to the


write requests que
Error adding the value to the write requests que

Error executing the SQL command

Error connecting to the server

Error writing data

Error computing the write buffer

104

48.

Write Variable

48.1. Description
The command Write Variable writes the actual value of the specified variable into the specified
PLC.
Warning!
The command Write Variable overrides the memory area of the PLC which is specified in the
variable definition. PLC Reports does not perform any data type validation of the PLCs destination
memory. Furthermore PLC Reports cannot validate the specified PLC memory address. Incorrect
definitions of data types or addresses may lead to overwrite unintended memory areas of the PLC.
Warning!
Make sure that writing to the specified PLC memory areas does not lead to unintended or dangerous
machine or plant conditions. Validate the write actions with the machine or plant manufacturer.
Warning!
Carefully validate each single write command and check its correct functionality. Never use write
commands in productions environments without prior validation and testing.

48.2. Parameters
The command requires one parameter: The index of the variable to be written.
48.2.1. Parameter 1: Index of the Variable
This parameter specifies the index of the variable to be written into the PLC. This parameter is always
required.
Valid values are indexes of defined variables.

48.3. Sample Application


Write Variable (1)
The result of a special calculation is written back into the PLC. A connected HMI displays the result in
the user interface of a machine.

48.4. Workflow of the Instruction


The instruction has the following workflow:
1. Check if the variable has a valid actual value.
a. Abort if no
2. Write the value to the specified PLC memory.

105

48.5. Possible Errors


Error Message

Explanation and Possible Error Cause

Invalid variable index

The variable index specified in parameter 1 is


not an integer.
The index specified in parameter 1 is an integer
number but no variable with that index is
defined.
Only variables with a valid actual value can be
written into the PLC
An error occurred while reading the variable
from the PLC. Further details can be found in the
message list.

There is no variable with index: xxx defined

The variable has no actual value


Error reading the value from the PLC

106

You might also like