Report Generation

Related Topics

This document describes the usage of the SAP xApp Manufacturing Integration and Intelligence (SAP xMII) reporting subsystem.  This component of the SAP xMII enables dynamically-generated HTML content to be created to provide comprehensive production reports combining data from multiple sources and multiple presentation formats into a format available for display or printing.

The reporting subsystem also provides techniques for passing parameters to a report to specify or narrow report content, format, or data.  The reporting system is implemented using a specialized servlet called "ReportServlet".  This servlet is automatically executed whenever a Web page ending in the SAP xMII report file extension, "irpt", is loaded from the Web server where the SAP xMII has been installed.

Visually, an SAP xMII report consists of an HTML page with "sections" that will be replaced at execution time with some other HTML content generated from an SAP xMII query.

The following sections will explain how to create reports as well as how to pass parameters to SAP xMII reports for truly interactive and dynamic information.

The SAP xMII HTML Wizard and the FrontPage Add-in make it extremely easy to generate HTML output for printing reports using your existing query and display templates.

Developing SAP xMII Reports

SAP xMII reports can be developed in virtually any HTML editor or text editor.  Report pages are essentially HTML pages with special tags embedded in the page to indicate where dynamic content should be inserted, as well as tags for specifying parameter and formatting information.  The SAP xMII wizards provide built-in capabilities for generating these embedded tags, both in the FrontPage 2000 Add-In and the standalone wizard.  Of course, the output from multiple SAP xMII queries can be embedded in a single report, providing the same "portal" functionality to reporting that the SAP xMII delivers in live Web views.

By combining standard HTML with the SAP xMII dynamic content, extensive control is provided over page layout, formatting, and inclusion of application-specific headers, logos, and other information.

In addition, the XML/XSL capabilities of the SAP xMII can be used to provide very fine-grained control over the appearance of dynamic data generated from an SAP xMII query.

Using The Servlet or Applet Tags

Report placeholders can be used in all areas of the head and body section of the Web page, but are not valid inside of any script blocks.  Dynamic content generated by the SAP xMII will typically be placed inside of either Servlet or Applet tags using one or more report parameters, but general areas of the body section can also use report parameters for dynamic text output.  Multiple instances or combinations of the servlet and applet tags can be used in a single SAP xMII report.  An example is shown as follows:

<SERVLET NAME="Illuminator">

<PARAM NAME="QueryTemplate" VALUE="Demo/Process/BatchListQuery">

<PARAM NAME="FilterExpr" VALUE="PlasticBottleBatchData.BatchID='{BatchNo}'">

<PARAM NAME="Content-Type" VALUE="text/xml">

<PARAM NAME="Stylesheet" VALUE="http://localhost/Styles/BlueTable.xsl">

</SERVLET>

The "NAME" parameter of the servlet tag indicates the name of the servlet to be executed.  In most cases, this will be the SAP xMII servlet.  There may be cases where third party content may be included using non-SAP xMII servlets.

Enclosed in the <SERVLET> tag are <PARAM> tags that contain name/value pairs that will be provided to the previously named servlet.  Note that in the above example, the FilterExpr parameter includes an embedded value in special syntax using enclosing curly brackets, as in {BatchNo}.  This will be discussed in more detail in the following section which describes passing parameters to a report.  Note:  You cannot pass HTML comment tags, such as "<!--PARAM NAME="StartDate" VALUE="07/29/2002 08:00:00"-->", enclosed within the <SERVLET> tag.

The easiest way to create the appropriate HTML code for including dynamic content via a servlet tag is to utilize the SAP xMII wizards.  However, it can be coded using the above syntax in virtually any HTML authoring environment without problems.

Passing Parameters To A Report

There are two basic techniques for passing parameter values to a report.  The first technique is using SAP xMII session properties, and the second uses name/value pairs included in the URL used to load the report.  Regardless of the technique used to get parameters to the report, a special embedded value syntax is used to tell the SAP xMII report system where values are to be substituted at execution time with values provided using either of the two techniques described previously.

For additional information on queries and parameters, refer to the Constructing Queries Guide and the Parameter Reference Guide.

Embedded Values

The syntax for embedding externally-provided values in a report is to use a placeholder name surrounded by curly brackets, as in {LotNumber} or {StartDate}.  When the report is executed, the SAP xMII will first check to see if a parameter has been passed as a session property (refer to the Applet Reference Guide for more details on how to assign a session property), then check if a parameter has been passed in the URL.  Values passed via the URL will always take precedence over session properties.  In the case where a placeholder is used but no value is provided, a default value of an empty string will be used to replace the placeholder.  It is important to remember that placeholders are replaced with the exact text of the passed-in value.

The following example demonstrates a simple batch report, with the parameters BatchNo, BatchStart, and BatchEnd being passed to the report.  Note the use of the placeholders, and the fact that the placeholder can be used multiple times within the report.  In this example, the passed-in batch number is being used to control filtering of data, as well as the title of the dynamically-generated GIF chart.

<html>

<head>

<title>Batch Detail Report</title>

<meta http-equiv="Pragma" content="no-cache">

</head>

<body>

<H2>Batch Report</H2>

<H3>HiPerf Plastics Corporation - Slattsburg Plant</H3>

<p>

<SERVLET NAME="Illuminator">

<PARAM NAME="QueryTemplate" VALUE="Demo/Process/BatchListQuery">

<PARAM NAME="FilterExpr" VALUE="PlasticBottleBatchData.BatchID='{BatchNo}'">

<PARAM NAME="Content-Type" VALUE="text/xml">

<PARAM NAME="StyleSheet" VALUE="http://localhost/Illuminator/Stylesheets/IllumRowsetTable.xsl">

</SERVLET>

</p>

<p>

<SERVLET NAME="ChartServlet">

<PARAM NAME="QueryTemplate" VALUE="Demo/Process/BatchTrendQuery">

<PARAM NAME="DisplayTemplate" VALUE="Demo/Process/BatchTrendChart">

<PARAM NAME="FilterExpr" VALUE="PlasticBottleTrendData.BatchNo='{BatchNo}'">

<PARAM NAME="StartDate" VALUE="{BatchStart}">

<PARAM NAME="EndDate" VALUE="{BatchEnd}">

<PARAM NAME="Width" VALUE="370">

<PARAM NAME="Height" VALUE="280">

<PARAM NAME="Title" VALUE="Profile For Batch {BatchNo}">

<PARAM NAME="ShowChart" VALUE="1">

<PARAM NAME="XAxisFontSize" VALUE="9">

<PARAM NAME="YAxisFontSize" VALUE="10">

<PARAM NAME="LegendFontSize" VALUE="10">

<PARAM NAME="HTMLPage" VALUE="true">

</SERVLET>

</p>

<p>

<SERVLET NAME="Illuminator">

<PARAM NAME="QueryTemplate" VALUE="Demo/Process/BatchTrendQuery">

<PARAM NAME="DisplayTemplate" VALUE="Demo/Process/BatchTrendChart">

<PARAM NAME="FilterExpr" VALUE="PlasticBottleTrendData.BatchNo='{BatchNo}'">

<PARAM NAME="Content-Type" VALUE="text/xml">

<PARAM NAME="StyleSheet" VALUE="http://localhost/Illuminator/Stylesheets/IllumRowsetTable.xsl">

</SERVLET>

</p>

</body>

</html>

 

The sample report above uses three separate <SERVLET> tags to include some general batch information, a chart of process conditions during the batch, and a detailed list of key process parameters during batch execution.  This sample also shows the use of XSL stylesheets to format output (see the Customizing Output Reference for more details) and how to suppress standard HTML tags when embedding output from an SAP xMII query in a report.

Additional Report Ideas

The following examples demonstrate how leveraging the power of the SAP xMII Reporting capabilities can not only cut down on Web page development time, but also reduce the time spent maintaining Web pages. With the ability to use parameters for simple things like page titles, the number of Web pages can be reduced and make the process of expanding a Website as simple as changing a parameter value in a href call.

In the head section of the sample report above, a parameter could be used to make the title of the page dynamic as follows:

<title>Batch {BatchNo} Detail Report</title>

The sample page above includes static text for the company name (HiPerf Plastics Corporation) as well as the specific plant location (Slattsburg), but a single page could be used for multiple plant locations as follows:

<H3>HiPerf Plastics Corporation - {PlantLocation} Plant</H3>

Passing Parameters Via The URL Request

In the previous example, the parameters values can be passed directly via the URL used to generate the report.  Let us suppose that the Batch report was in a file called BatchReport.irpt, and was in the Reports directory on the Web server.  In this case, the URL could look something like:

http://<servername>/Reports/BatchReport.irpt?BatchNo=X123&BatchStart=9/15/2000 10:04:10&BatchEnd=9/15/2000 10:56:43

Note that the URL parameters correspond exactly to the names of the embedded value placeholders.  A question mark (?) follows the report file name, and an ampersand sign (&) separates each name/value pair.

Advanced Reporting Techniques

With a little bit of creativity and by harnessing the depth of functionality included in the SAP xMII product, very cool techniques for reporting can be deployed in your applications.

Dynamic Format Control For Multiple Output Devices

Virtually any aspect of the report and the underlying queries that generate the report can be controlled dynamically.  Thus, not only can data selection behavior be passed in dynamically, but formatting information, such as stylesheets, can be also be passed in as placeholders.  This provides a powerful means for delivering device-specific formatting, allowing a report to target a printer, a Web browser, or a microbrowser on a PDA from a single report.

Creating Automatically Updating Or "Live" Reports

Since an SAP xMII report is nothing more than a standard HTML page with a specific file extension and a set of special tags, it is certainly possible to create "living" reports using various techniques to cause the page to automatically refresh itself, such as the META refresh tag.

Leveraging XSL Stylesheets For Total Formatting Control

As mentioned earlier, combining the new XSL formatting capabilities of the SAP xMII with the reporting subsystem offers complete control over the output of SAP xMII data into virtually any desired appearance.  The key to using this technique is to set the Content-Type parameter to "text/xml" via a <PARAM> tag inside the <SERVLET> tag, then provide a the Stylesheet parameter via another <PARAM> tag.  The stylesheet is a reference to a physical file or URL on the Web server (see the Customizing Output - Specifying Stylesheets section for more details).  Finally, the "media-type" parameter in the XSL stylesheet should be set to "text/html" in order to generate a stream of HTML output that can be included in the report.

Embedding an Image in a Report

See the section on using the dynamic image linking using the ChartServlet and the SPCChartServlet for information.