Promotic

PmaReport - Deatiled object description

See: the PmaReport object.

The object serves for creating reports from HTML, XML or TXT template files (these templates must be formated as described in Source file description of the PmaReport object). The reports created by the PmaReport object can be used, for example, for following purposes:
- for displaying in the window of the PROMOTIC application or in the Web client. For some specific purposes it is more useful to use PmaReport than the PmaPanel object.
It is mainly connected with situations, when large amounts of data is to be displayed as tables, that are not being updated very often. The PmaReport object window can be opened exactly the same way as PmaPanel window, i.e. by the Pm.CreateView method (see Example2).
- for printer outputs, i.e. for example for creating multipage print reports. It can be easily done by the PmaReport.SaveToString and Pm.PrintHtmlPage methods (see Example2).
- to save it to disk in the form of HTML (XML,TXT) files by the SaveToFile method.


The PmaReport object will, by means of expressions and keywords, process a text transformation over the source template (HTML, XML, TXT page) resulting in creation of output report. The transformation is processed by filling in the values, proporties and tag styles (using the keywords) with the possibility of unfolding or hiding a portion of the report template. The output report can be displayed, printed or returned in text variable.

Regarding updating the new values, there are two basic ways of using the PmaReport object:
1st Updating the report while the final output report is being read:
For this purpose, the onReportRequest event can be used, initialized at the beginning of the report content reading. In this event, it is possible to provide the changed values of keywords (by the SetKeyValue method), to read another source file, or re-read the current file (by changing the SourceFile property). If the keyword values and/or the template has been changed, then it is necessary to enter 1 into the pEvent.Modify output parameter, that will result in creation of new updated report. See Example1.
2nd Update the report independently on output report reading:
In this mode, the update is processed from the application by means of the scripting methods, independently, not related to report reading. The script can be used to provide modified keyword values (by the SetKeyValue method), read another template file, or re-read the current file (by changing the SourceFile property). If the keyword values and/or the template has been changed, then it is necessary to create the current updated report by the MakeReport method. This allows to controll the report updates from another part of the application, for example from PmaTimer (handy for example for regular print report updates). See Example2.


Example1:
The example of the report update with own reading (according to the no. 1). The script is located in the onReportRequest event. The value of the color keyword will be replaced by expression #ff0000 in the source file.
JavaScriptVBScriptSelect and copy to clipboard

pMe.SetKeyValue("color", "#ff0000");
pEvent.Modify = 1;
Example2:
The example of updating the report independently on reading (manual way no. 2). The script can be located anywhere outside the onReportRequest event. The value of the color keyword will be replaced by RGB color #ff0000.
JavaScriptVBScriptSelect and copy to clipboard

var oReport, oWorkspace, sReport;
oReport = pMe.Pm("/Report");   // Path to the PmaReport object
oReport.SetKeyValue("color", "#ff0000");
oReport.MakeReport();

// Furthermore the content of the PmaReport object will be displayed in the workspace window (in the PmaWorkspace object):
oWorkspace = pMe.Pm("/Workspace");   // Path to the PmaWorkspace object
var oCreator = Pm.CreateView(oWorkspace, "/Report", "", "target:main;");
oCreator.Open();

// Furthermore the content of the PmaReport object will be sent to printer:
sReport = oReport.SaveToString("");
Pm.PrintHtmlPage(sReport, "sourcetype:htmlstring;printer:select;");
Example3:


There is a loaded, pre-processed report template in the object followed by the keyword set with values parametrizing the transformation (these are key and value pairs) supplemented by the last output report in the object's cache. By means of keywords, it is possible to put a large amount of updated values into the report from the application. It is possible to transfer the values of any data type (Variant), but also 1-dimensional array and 2-dimensional array. For using the keywords for transforming the template into the output report - see Source file description of the PmaReport object.

For similar purpose as the PmaReport object the PmaWebDir object can be used. It is much more simple and less general. It is used only for offering static HTML pages with the possibility of simple keyword replacement.

Comparison of the PmaReport object with the PmaPanel object:
The Advantages of the PmaReport object:
- easy creation of multiple page reports for printing.
- easy creation of reports containing large ammounts of data.
- the texts are adopted to the width of the page (if HTML report).
Disadvantages of the PmaReport object:
- when creating the report, basic HTML skills are necessary
- when creating the report, the statements described in Source file description of the PmaReport object must be known.
- it is not suitable for displaying data with high refresh rate.
PROMOTIC 9.0.27 SCADA system documentation MICROSYS, spol. s r.o.

Send page remarkContact responsible person
© MICROSYS, spol. s r.o.