24
How to Integrate xMII Templates in the SAP PI Sheet SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com How to Integrate xMII Templates in the SAP PI Sheet Applies to: Brower-based PI sheet (SAP application component PP-PI-PMA-PMC) in SAP R/3 4.6c or higher for the chapters without the XSteps SAP Enterprise 4.70 Extension 2.0 or higher for all chapters SAP xMII 11.5 SAP Netweaver 04s Summary Explains how to integrate xMII display templates in the SAP PI Sheet. Contains information about necessary master data settings, as well as tips and tricks for the application integration. Author: Dr. Ralf Markus Company: SAP AG Created on: 10 April 2007 Author Bio Dr. Ralf Markus joined the development organisation of SAP in 2001. He has an expertise in SAP PP-PI-PMA components (especially PI Sheet, Process Coordination, Electronic Batch Record [EBR], Execution Steps [XSteps]) and knowledge about xMII development. © 2007 SAP AG 1

How to Integrate xMII Templates in the SAP PI Sheet...How to Integrate xMII Templates in the SAP PI Sheet Applies to: Brower-based PI sheet (SAP application component PP-PI-PMA-PMC)

  • Upload
    others

  • View
    42

  • Download
    3

Embed Size (px)

Citation preview

Page 1: How to Integrate xMII Templates in the SAP PI Sheet...How to Integrate xMII Templates in the SAP PI Sheet Applies to: Brower-based PI sheet (SAP application component PP-PI-PMA-PMC)

How to Integrate xMII Templates in the SAP PI Sheet

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com

How to Integrate xMII Templates in the SAP PI Sheet

Applies to: Brower-based PI sheet (SAP application component PP-PI-PMA-PMC) in

• SAP R/3 4.6c or higher for the chapters without the XSteps • SAP Enterprise 4.70 Extension 2.0 or higher for all chapters

SAP xMII 11.5

SAP Netweaver 04s

Summary Explains how to integrate xMII display templates in the SAP PI Sheet. Contains information about necessary master data settings, as well as tips and tricks for the application integration.

Author: Dr. Ralf Markus

Company: SAP AG

Created on: 10 April 2007

Author Bio

Dr. Ralf Markus joined the development organisation of SAP in 2001. He has an expertise in SAP PP-PI-PMA components (especially PI Sheet, Process Coordination, Electronic Batch Record [EBR], Execution Steps [XSteps]) and knowledge about xMII development.

© 2007 SAP AG 1

Page 2: How to Integrate xMII Templates in the SAP PI Sheet...How to Integrate xMII Templates in the SAP PI Sheet Applies to: Brower-based PI sheet (SAP application component PP-PI-PMA-PMC)

How to Integrate xMII Templates in the SAP PI Sheet

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com

Table of Contents

Business Context............................................................................................................................. 3

Prerequisites.................................................................................................................................... 4

xMII Templates............................................................................................................................. 4

Accessing the xMII Template....................................................................................................... 5

SAP Web Repository ................................................................................................................... 8

Unicode .................................................................................................................................... 8

RFC Connection to xMII............................................................................................................... 9

Simple Frameset in the PI Sheet with or without XSteps .............................................................. 11

Complex Frameset in the PI Sheet................................................................................................ 13

Pre-Settings: Display Query Results as table............................................................................ 13

Integration with Process Instructions............................................................................................. 14

Integration with XSteps.................................................................................................................. 14

Direct Integration (without Frameset) in the PI Sheet using Process Instructions ........................ 15

Direct Integration (without Frameset) in the PI Sheet using XSteps ............................................. 16

Source code of the used function module ..................................................................................... 18

Copyright ....................................................................................................................................... 22

© 2007 SAP AG 2

Page 3: How to Integrate xMII Templates in the SAP PI Sheet...How to Integrate xMII Templates in the SAP PI Sheet Applies to: Brower-based PI sheet (SAP application component PP-PI-PMA-PMC)

How to Integrate xMII Templates in the SAP PI Sheet

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com

Business Context

The PI sheet represents the result of a control recipe that was sent to a process operator and whose content is displayed as text on the screen. This means the PI sheet is an instruction for the process operator that describes how and in which order a product is manufactured. The PI sheet can, for example, contain information about the picking of raw materials as well as instructions about charging the mixer, filling silos, and so on.

The SAP PI sheet is designed for processing on the screen, which means that the process operator should enter, confirm, report, or complete data interactively. In this way, the PI sheet enables communication between the SAP system and process operators on production lines that are operated manually (either fully or partially).

Depending on the characteristic-based process instructions or XSteps contained in a control recipe, the PI sheet supports the display of control information. The integration of xMII display templates in the PI sheet is needed for better visualization of MES data that is relevant to production.

For the scenario only the integration of xMII display templates in the PI Sheet is described. Manipulation of the visualized xMII data with the PI Sheet acting as a trigger for changes in the Display template is not shown.

Integration of xMII display templates

• by a frameset is done by referencing an HTML page in the existing process instruction characteristic PPPI_LAYOUT. It is done in the same way when XSteps are used.

• without a frameset but directly in the PI sheet is done using the existing process instruction characteristic PPPI_INSTRUCTION. In this characteristic, an HTML page is integrated by the HTML tag iframe.

• without a frameset but directly in the PI sheet is done - when using XSteps - using the existing process instruction characteristic PPPI_FRAGMENT_HTML. In this characteristic, an HTML page is integrated by the HTML tag iframe.

© 2007 SAP AG 3

Page 4: How to Integrate xMII Templates in the SAP PI Sheet...How to Integrate xMII Templates in the SAP PI Sheet Applies to: Brower-based PI sheet (SAP application component PP-PI-PMA-PMC)

How to Integrate xMII Templates in the SAP PI Sheet

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com

Prerequisites

In order for the xMII templates to be called, they must first be created in the xMII environment. A general introduction for working and configuring xMII and templates is available:

SAP xMII Getting Started Guide

SAP xMII Best Practices Guide

How to Configure XMII 11.5.1 Build 63 and IIS 6.0 for https

For the current scenario a running and configured xMII system has to be available. For the current example only the most important steps are outlined.

xMII Templates

Two query templates and one display template are created. A TagQuery is used for the query templates. Furthermore, a subfolder AGTEST is created in the xMII standard template folder. The subfolder is used for saving the relevant templates.

There are two query templates which are displayed differently:

• One is displayed as table in the PI sheet. For the scenario in this document, the ‘RFCtags’ template from Calling Services and Queries in SAP xMII 11.5 from ABAP (page 20) is reused.

• The other is used as data source for an applet displayed in the PI sheet. For the query template a display template (grid, chart, etc.) is necessary for visualization. An iChart template is used for the example in this document (Figure 1).

© 2007 SAP AG 4

Page 5: How to Integrate xMII Templates in the SAP PI Sheet...How to Integrate xMII Templates in the SAP PI Sheet Applies to: Brower-based PI sheet (SAP application component PP-PI-PMA-PMC)

How to Integrate xMII Templates in the SAP PI Sheet

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com

Figure 1: Data for the iChart Template

For the applet (direct integration in the PI sheet without a frameset), there are finally two templates in the subfolder AGTEST: a query template ‘QueryForApplet’ and a display template ‘DisplayForApplet’ (see Figure 2).

Figure 2: Data of the Two Templates

Accessing the xMII Template

The central element for calling the xMII templates is a static HTML page that is included in the PI sheet. The integration of xMII display templates in the PI sheet is done by calling this static HTML page that includes a static URL referencing the xMII service. The URL does not call another dynamic xMII HTML page: it directly accesses the templates.

© 2007 SAP AG 5

Page 6: How to Integrate xMII Templates in the SAP PI Sheet...How to Integrate xMII Templates in the SAP PI Sheet Applies to: Brower-based PI sheet (SAP application component PP-PI-PMA-PMC)

How to Integrate xMII Templates in the SAP PI Sheet

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com

The HMTL page („caller HTML“) has the following coding

<HTML>

<HEAD>

<META Name="Content-Type" Value="text/html;charset=utf-8">

<script language="JavaScript">

function openLink()

{

location.href="http://iwdfvm1087:1080/Lighthammer/DynamicPageServlet?btnGeneratePage=Generate+Page&Height=400&Width=640&QueryTemplate=AGTEST/QueryForApplet&DisplayTemplate=AGTEST/DisplayForApplet&Applet=iChart&RefreshRate=5&IllumLoginName=[Loginname for xMII]&IllumLoginPassword=[Password for xMII]&session=true";

}

</SCRIPT>

</HEAD>

<BODY onLoad=openLink()>

</BODY>

</HTML>

The only purpose of this source code is to automatically call the link of location.href via JavaSchript when the HTML page is loaded. The <HEAD>-tag of the HTML page defines a JavaScript function openLink() for this purpose. This function hyperlinks the displayed content of the final page by URL. Within the <BODY>-tag of the HTML page, the openLink()function is executed when the HTML page itself is loaded(onLoad).

The URL to be called after location.href consists of several parts which are explained in detail:

http://iwdfvm1087:1080/Lighthammer/

http:://Address of the xMII Server:Port/Path Prefix/

DynamicPageServlet?btnGeneratePage=Generate+Page&Height=400& Width=640&

Name of xMIIService?Option for generating Page=Generate command for a Page&Height of the applets=400 pixel&Width of the applet=640 pixel&

QueryTemplate=AGTEST/QueryForApplet&

QueryTemplate=Folder where the QueryTemplate is stored/Name of the QueryTemplate&

DisplayTemplate=AGTEST/DisplayForApplet&

DisplayTemplate =Folder where the DisplayTemplate is stored/Name of the DisplayTemplate&

© 2007 SAP AG 6

Page 7: How to Integrate xMII Templates in the SAP PI Sheet...How to Integrate xMII Templates in the SAP PI Sheet Applies to: Brower-based PI sheet (SAP application component PP-PI-PMA-PMC)

How to Integrate xMII Templates in the SAP PI Sheet

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com

Applet=iChart&RefreshRate=5&

&Applet= Type of theDisplayTemplate & refresh rate= 5 Sec&

Up to here this part of the URL can be generated by the Dynamic Page Generator in xMII. Opening this URL in a Web browser can be used to test the validity of the URL (see Figure 3).

Figure 3: Web Browser Displaying URL http://iwdfvm1087:1080/Lighthammer/DynamicPageServlet?btnGeneratePage=Generate+Page&Height=400&Width=640&QueryTemplate=AGTEST/QueryForApplet&DisplayTemplate=AGTEST/DisplayForApplet&Applet=iChart&RefreshRate=5

To enable an automatic logon for the user to the server, it is necessary to add another part to the URL:

IllumLoginName=[Loginname for xMII]&IllumLoginPassword=[Password for xMII]&session=true";

This last part of the URL contains the login parameters, which are the user’s name and the password. The session=true statement ensures that the user stays logged on to the system, otherwise a repeated logging on would happen. Just replace the [Loginname for xMII] and [Password for xMII] with the corresponding data.

© 2007 SAP AG 7

Page 8: How to Integrate xMII Templates in the SAP PI Sheet...How to Integrate xMII Templates in the SAP PI Sheet Applies to: Brower-based PI sheet (SAP application component PP-PI-PMA-PMC)

How to Integrate xMII Templates in the SAP PI Sheet

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com

The complete URL was created for the current scenario. If another context or other templates are used, the URL must be adjusted. This adjusted URL must simply be copied after location.href replacing the current URL in the code sample of the HTML page (i.e. chapter Pre-Settings: Display Query Results as Table).

SAP Web Repository

After saving the now so-called ‘‘caller HTML’’ locally and remembering the folder path for later use, you can test the functionality of the page by opening it in a Web browser. If the applet does not correctly display the URL, you should check the Web browser and network settings. Otherwise the HTML page can be uploaded to the SAP Web Repository, which can be accessed via SAP Menu -> Tools -> Web Development -> Web Repository.

After invoking the transaction, you should choose Binary Data for WebRFC Applications on the first screen. On the next screen, you must choose a package to which the HTML page should be assigned. A valid entry would be $TMP.

You must create a new object in the chosen package. If the SAP system is a Unicode system, the name of the object must have the prefix Z_TML_. It is better to proceed as in a Unicode system in the case of a non-Unicode system too. For details, refer to the next chapter “Unicode”. The object for the ‘caller HTML’ in the current example has the name Z_TML_ZXMII_ACCESS.HTML. In the same popup in which the object name is defined, there is a button for uploading the ‘caller HTML’ from the front end. When the import has been completed, the ‘caller HTML’ can subsequently be accessed in the SAP.

Unicode

To ensure compatibility with Unicode, the HTML page must be converted to a Unicode codepage. You are recommended to use the Unicode encoded HTML page for a non-Unicode system too, because Web browsers often use Unicode as standard encoding.

To convert the HTML page to Unicode, execute the SAP program RCMX_BFW_BUILD_RUNTIME_FILES and enter the following on the selection screen:

• For the development class, enter the name of the package in which the HTML file is stored in the SAP Web Repository (here: $TMP)

• The name of the original must be the name of the source (or template) file without the prefix Z_TML_ (here: ZXMII_ACCESS.HTML). The HTML page is later integrated into the PI sheet under this name.

After a successful execution of the program the following screen should appear:

© 2007 SAP AG 8

Page 9: How to Integrate xMII Templates in the SAP PI Sheet...How to Integrate xMII Templates in the SAP PI Sheet Applies to: Brower-based PI sheet (SAP application component PP-PI-PMA-PMC)

How to Integrate xMII Templates in the SAP PI Sheet

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com

Figure 4: Final Screen after Successful Conversion to Unicode Codepage utf-8.

In case of an error, you are recommended to check the name of the template HTML file and the name of the original file. A syntax check of the HTML source code is also necessary.

RFC Connection to xMII

An RFC connection to the xMII server is mandatory to access xMII services. To create a new RFC connection, follow the path SAP Menu -> Logistics -> Logistics Execution -> Internal Whse Processes -> Communication with External Systems -> ALE Administration -> Runtime Settings -> Maintain RFC Destinations and create a new RFC connection of the type G (HTTP connections to external server). In the current example this RFC connection is called SAP_XMII TEST and has the technical settings as shown in Figure 5 to successfully access the xMII Server.

© 2007 SAP AG 9

Page 10: How to Integrate xMII Templates in the SAP PI Sheet...How to Integrate xMII Templates in the SAP PI Sheet Applies to: Brower-based PI sheet (SAP application component PP-PI-PMA-PMC)

How to Integrate xMII Templates in the SAP PI Sheet

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com

Figure 5: Settings for Accessing xMII Server

The ‘Target Host’ (Figure 5) must contain the complete URL of the xMII server. The ‘Path Prefix’ must contain the prefix for the start page of xMII.

The ‘Service No.’ in Figure 5 must be the same as the port number of the ‘Default Web Site’ of the Internet Information Services (IIS). This ‘Default Web Site’ can be accessed by Windows -> Start-> Control Panel -> Administrative Tools -> Internet Information Services (see Figure 6).

Figure 6: Screenshot of the Internet Information Services

In Figure 6 right click on the entry ‘Default Web Site’ and choose the entry “Properties” from the context menu. On the following screen (Figure 7) the entry for ‘TCP Port’ must be the same as ‘Service No:’ in Figure 5. If the numbers are different one of them must be changed.

© 2007 SAP AG 10

Page 11: How to Integrate xMII Templates in the SAP PI Sheet...How to Integrate xMII Templates in the SAP PI Sheet Applies to: Brower-based PI sheet (SAP application component PP-PI-PMA-PMC)

How to Integrate xMII Templates in the SAP PI Sheet

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com

Figure 7: Screenshot of the ‘Properties’ Popup for Default Web Site

After adjusting the network settings and the RFC connection to the scenario, you can test the RFC connection. The latter should work correctly.

Simple Frameset in the PI Sheet with or without XSteps

The PI sheet can be defined with the ‘caller HTML’ available in the SAP Web Repository (here: ZXMII_ACCESS.HTML).

Process Instructions

Create a process instruction of the type TYP0 containing only one characteristic PPPI_LAYOUT at the beginning of the PI sheet. Include the HTML page in the long text of the characteristic with the following coding:

<?xml version=“1.0“?>

<LAYOUT>

<FRAMESET ROWS=“20%,80%“>

© 2007 SAP AG 11

Page 12: How to Integrate xMII Templates in the SAP PI Sheet...How to Integrate xMII Templates in the SAP PI Sheet Applies to: Brower-based PI sheet (SAP application component PP-PI-PMA-PMC)

How to Integrate xMII Templates in the SAP PI Sheet

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com

<FRAME SRC=”SAPR3-WR-ZXMII_ACCESS.HTML”></FRAME>

<FRAME SRC=”#DOCUMENT#”></FRAME>

</FRAMESET>

</LAYOUT>

”SAPR3-WR-“ is the mandatory prefix of the Web Repository where the HTML page is stored. In the example given, two frames are defined: one for the xMII display template and the other for the PI sheet. The result should look like Figure 8 for the example scenario.

Figure 8: Simple Frameset with xMII Display template and PI Sheet

XSteps

To create a simple Frameset with XSteps just follow the instructions in chapter ‘Integration with XSteps’ and use the above given long text for the PPPI_LAYOUT definition for XSteps.

© 2007 SAP AG 12

Page 13: How to Integrate xMII Templates in the SAP PI Sheet...How to Integrate xMII Templates in the SAP PI Sheet Applies to: Brower-based PI sheet (SAP application component PP-PI-PMA-PMC)

How to Integrate xMII Templates in the SAP PI Sheet

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com

Complex Frameset in the PI Sheet

For the complex Frameset the already used simple Frameset is extended. The second template to be integrated is the Query Template displayed as a table which is described in chapter ‘xMII templates’. The result should look like Figure 9 regardless if it is integrated with Process Instructions or with XSteps.

Figure 9: Complex Frameset with the PI Sheet

Pre-Settings: Display Query Results as table

First of all in the xMII the QueryTemplate is stored in the template directory of xMII. The name of the QueryTemplate and the name of the subfolder (here: AGTEST, see chapter ‘Accessing the xMII Template’) should be remembered for later usage.

Then open at the front end the ‘caller HTML’ (here: Z_TML_ZXMII_ACCESS.HTML) and replace the URL after location.href with

http://iwdfvm1087:1080/Lighthammer/Illuminator?QueryTemplate=AGTEST/Querytemplate&IllumLoginName=user&IllumLoginPassword=password

The part &IllumLoginName=user&IllumLoginPassword=password is optional. It does not influence the functionality in the current example. The URL is similar to the URL for calling the Applet (Chapter “Accessing the xMII Template”): one new part is

Illuminator?QueryTemplate=AGTEST/Querytemplate&

Name of the Service?Name of the Folder=AGTEST/Name of the template&

After changing the URL save the file with a new name (here: Z_TML_Z_XMII_ACCESS_TAB.HTML). Execute for this HTML all the steps described in chapter ‘SAP Web Repository’.

© 2007 SAP AG 13

Page 14: How to Integrate xMII Templates in the SAP PI Sheet...How to Integrate xMII Templates in the SAP PI Sheet Applies to: Brower-based PI sheet (SAP application component PP-PI-PMA-PMC)

How to Integrate xMII Templates in the SAP PI Sheet

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com

Integration with Process Instructions

Create a Process Instruction of type TYP0 at the beginning of the PI Sheet containing only one characteristic PPPI_LAYOUT. Include the ‘caller HTML’ pages with the following coding in the long text of the characteristic:

<?xml version=“1.0“?>

<LAYOUT>

<FRAMESET ROWS=“40%,60%“>

<FRAMESET ROWS=“55%,45%“>

<FRAME SRC=”SAPR3-WR-ZXMII_ACCESS.HTML”></FRAME>

<FRAME SRC=”SAPR3-WR-ZXMII_ACCESS_TAB.HTML”></FRAME>

</FRAMESET>

<FRAME SRC=”#DOCUMENT#”></FRAME>

</FRAMESET>

</LAYOUT>

The defined Frameset consists of three Frames: In the first two frames (grouped in another Frameset) the HTML pages from the SAP Web Repository are loaded. In the third frame the PI Sheet is loaded.

Integration with XSteps

Create a Process Instruction (Figure 10: Layout) at the beginning of the PI Sheet containing only one characteristic PPPI_LAYOUT. Include the ‘caller HTML’ pages with the coding of chapter ‘Integration with Process Instructions’ in the long text of the characteristic (Figure 10).

Figure 10: Settings for a complex Frameset defined by XSteps

© 2007 SAP AG 14

Page 15: How to Integrate xMII Templates in the SAP PI Sheet...How to Integrate xMII Templates in the SAP PI Sheet Applies to: Brower-based PI sheet (SAP application component PP-PI-PMA-PMC)

How to Integrate xMII Templates in the SAP PI Sheet

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com

Direct Integration (without Frameset) in the PI Sheet using Process Instructions

For including the display template (Figure 8) directly in the PI Sheet without a Frameset a Process Instruction of type INSTR must be used. This Instruction should contain only one characteristic PPPI_INSTRUCTION with the following coding as long text:

<table cellspacing="0" cellpadding="0" border="1" frame="box">

<tr>

<td>

<iframe src="SAPR3-WR-ZXMII_ACCESS.HTML"

width="640" height="400" scrolling="No" id="_SELECT_"

marginwidth="0" marginheight="0"> No Display

</iframe>

</td>

</tr>

</table>

The source code must be formatted with HT HTML for successfully executing the HTML code. In the code an iframe element is used which has a scr attribute containing the URL of the included HTML page (here: SAPR3-WR-ZXMII_ACCESS.HTML). When executing this scenario the result looks like this:

Figure 11: Integrated Applet in the PI Sheet

© 2007 SAP AG 15

Page 16: How to Integrate xMII Templates in the SAP PI Sheet...How to Integrate xMII Templates in the SAP PI Sheet Applies to: Brower-based PI sheet (SAP application component PP-PI-PMA-PMC)

How to Integrate xMII Templates in the SAP PI Sheet

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com

Direct Integration (without Frameset) in the PI Sheet using XSteps

For including the display template (Figure 8) directly in the PI Sheet without a Frameset using XSteps the structure of Figure 12 is used: A Process Instruction of type TYP0 including three characteristics.

Figure 12: Definition with HTML Fragment for integration of the Applet in the PI Sheet

The long text of PPPI_FRAGMENT_HMTL (Process Instruction Characteristic of type HTML Fragment) contains the coding

<table cellspacing="0" cellpadding="0" border="1" frame="box">

<tr>

<td>

<iframe src="SAPR3-WR-ZXMII_ACCESS.HTML"

width="640" height="400" scrolling="No" id="_SELECT_"

marginwidth="0" marginheight="0"> No Display

</iframe>

</td>

</tr>

</table>

This is the same coding used for Direct Integration in the PI Sheet using Process Instructions. For displaying the PI Sheet a Control Recipe for test should be created since the Simulation of XSteps has some Limitations (see SAP Notes 715897 and 993337).

© 2007 SAP AG 16

Page 17: How to Integrate xMII Templates in the SAP PI Sheet...How to Integrate xMII Templates in the SAP PI Sheet Applies to: Brower-based PI sheet (SAP application component PP-PI-PMA-PMC)

How to Integrate xMII Templates in the SAP PI Sheet

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com

Displaying Query Results with PPPI_OUTPUT_VARIABLE

To access single values of the QueryTemplate described in chapter ‘Pre-Settings: Display Query Results as table’ the procedure described in Calling Services and Queries in SAP xMII 11.5 from ABAP (page 11f.) is used. With this guide as Basis and reference for explanatory details the necessary changes and adjustments to work with these settings in the current scenario are documented here.

Figure 13: Syntax of the used Process Instruction (TYP0)

A Function module Z_XMII_TAG_VALUE_GET2 is used which has some modifications (see chapter ‘Source code of the used function module’) compared to the original Z_XMII_TAG_VALUE_GET of Calling Services and Queries in SAP xMII 11.5 from ABAP.

For security reasons the Value for I_USER_NAME and I_USER_PASSWORD are not shown here but they have to be inserted in line 0070 and line 0090 to execute this example. The defined RFC Connection "SAP_XMII TEST” (see chapter ‘RFC Connection to xMII’) is used to access the xMII Server. As well the template folder and a QueryTemplate must be provided.

With these import parameters a URL is generated (see chapter ‘Source code of the used function module’: Source code after comment * build path ) for accessing the xMII. This is a different approach than the one described up the now: no longer a ‘caller HTML’ with the necessary URL is loaded automatically. The URL is built and called during runtime after user action.

© 2007 SAP AG 17

Page 18: How to Integrate xMII Templates in the SAP PI Sheet...How to Integrate xMII Templates in the SAP PI Sheet Applies to: Brower-based PI sheet (SAP application component PP-PI-PMA-PMC)

How to Integrate xMII Templates in the SAP PI Sheet

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com

Source code of the used function module

FUNCTION z_xmii_tag_value_get2. *"---------------------------------------------------------------------- *"*"Local Interface: *" IMPORTING *" VALUE(I_USER_NAME) TYPE TEXT40 *" VALUE(I_USER_PASSWORD) TYPE TEXT40 *" VALUE(I_RFC_DESTINATION) TYPE RFCDEST *" VALUE(I_TEMPLATE_FOLDER) TYPE TEXT40 *" VALUE(I_TEMPLATE_NAME) TYPE TEXT40 *" EXPORTING *" REFERENCE(E_TAG_VALUE) TYPE EPM_VALUE *" REFERENCE(E_BAPIRET) TYPE BAPIRET2 *" EXCEPTIONS *" HTTP_DEST_NOT_FOUND *" HTTP_COMMUNICATION_FAILURE *" NO_XML_DOCUMENT *"---------------------------------------------------------------------- DATA: client TYPE REF TO if_http_client, path TYPE string, value TYPE string, if_query_field TYPE LINE OF tihttpnvp, it_query_field TYPE tihttpnvp, if_str TYPE string, if_query TYPE string, if_response TYPE xstring, ref_document TYPE REF TO if_ixml_document, row_items TYPE REF TO if_ixml_node_collection, row_node TYPE REF TO if_ixml_node, row_node_element TYPE REF TO if_ixml_element, childelements TYPE REF TO if_ixml_node_list, childnode TYPE REF TO if_ixml_node, childnode_element TYPE REF TO if_ixml_element, datetimeelement TYPE REF TO if_ixml_element, if_tag_data LIKE epm_kpi_data, if_timestamp TYPE timestamp, ilen TYPE i, jlen TYPE i. * create http client object CALL METHOD cl_http_client=>create_by_destination EXPORTING destination = i_rfc_destination IMPORTING client = client EXCEPTIONS argument_not_found = 1 destination_not_found = 2 destination_no_authority = 3 plugin_not_active = 4 internal_error = 5

© 2007 SAP AG 18

Page 19: How to Integrate xMII Templates in the SAP PI Sheet...How to Integrate xMII Templates in the SAP PI Sheet Applies to: Brower-based PI sheet (SAP application component PP-PI-PMA-PMC)

How to Integrate xMII Templates in the SAP PI Sheet

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com

OTHERS = 6. IF sy-subrc <> 0. RAISE http_dest_not_found. ENDIF.

* set request method CALL METHOD client->request->set_header_field EXPORTING name = '~request_method' value = 'GET'. * build path CONCATENATE '?' 'QueryTemplate=' I_TEMPLATE_FOLDER '/' I_TEMPLATE_NAME '&Content-Type=text/xml' '&IllumLoginName=' I_USER_NAME '&IllumLoginPassword=' I_USER_PASSWORD INTO path. CALL METHOD client->request->set_header_field EXPORTING name = '~request_uri' value = path. * send request CALL METHOD client->send EXCEPTIONS http_communication_failure = 1 OTHERS = 4. IF sy-subrc <> 0. CALL METHOD client->close( ). RAISE http_communication_failure. ENDIF. * get response CALL METHOD client->receive EXCEPTIONS http_communication_failure = 1 http_invalid_state = 2 http_processing_failed = 3 OTHERS = 4. IF sy-subrc <> 0. CALL METHOD client->close( ). RAISE http_communication_failure. ENDIF.

© 2007 SAP AG 19

Page 20: How to Integrate xMII Templates in the SAP PI Sheet...How to Integrate xMII Templates in the SAP PI Sheet Applies to: Brower-based PI sheet (SAP application component PP-PI-PMA-PMC)

How to Integrate xMII Templates in the SAP PI Sheet

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com

* check that return is an xml document IF client->response->get_header_field( 'content-type' ) <> 'text/xml'. RAISE no_xml_document. ENDIF. if_response = client->response->get_data( ). CALL FUNCTION 'SDIXML_XML_TO_DOM' EXPORTING xml = if_response IMPORTING document = ref_document EXCEPTIONS invalid_input = 1 OTHERS = 2. IF sy-subrc <> 0. CALL METHOD client->close( ). RAISE no_xml_document. ENDIF. * look for error messages in xml document row_items = ref_document->get_elements_by_tag_name( name = 'FatalError' depth = 2 ). ilen = row_items->get_length( ). IF ilen > 0. * get actual Error element row_node = row_items->get_item( 0 ). row_node_element ?= row_node->query_interface( ixml_iid_element ). e_bapiret-message = row_node_element->get_value( ). ENDIF. * get list of <Row> elements row_items = ref_document->get_elements_by_tag_name( name = 'Row' depth = 2 ). * iterate over list ilen = 0. WHILE ilen < row_items->get_length( ). * get actual <Row> element row_node = row_items->get_item( ilen ). row_node_element ?= row_node->query_interface( ixml_iid_element ). * read <DateTime> child element and assign to if_timestamp datetimeelement = row_node_element->find_from_name( name = 'DateTime' ). if_str = datetimeelement->get_value( ). PERFORM adjust_timestamp USING if_str CHANGING if_timestamp. * loop over all children of this <Row> element childelements = row_node_element->get_children( ). jlen = 0. WHILE jlen < childelements->get_length( ). CLEAR: if_tag_data. * get actual child element childnode = childelements->get_item( jlen ). childnode_element ?=

© 2007 SAP AG 20

Page 21: How to Integrate xMII Templates in the SAP PI Sheet...How to Integrate xMII Templates in the SAP PI Sheet Applies to: Brower-based PI sheet (SAP application component PP-PI-PMA-PMC)

How to Integrate xMII Templates in the SAP PI Sheet

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com © 2007 SAP AG 21

childnode->query_interface( ixml_iid_element ). * process only those elements which are not of time time stamp IF ( childnode_element->get_name( ) <> datetimeelement->get_name( ) ). * fill return structure and append if_tag_data-kpi_id = childnode_element->get_name( ). if_str = childnode_element->get_value( ). MOVE if_str TO if_tag_data-value. if_tag_data-creationdate = if_timestamp. if_tag_data-uname = sy-uname. e_tag_value = if_tag_data-value. ENDIF. jlen = jlen + 1. ENDWHILE. " end loop over jlen ilen = ilen + 1. ENDWHILE. " end loop over ilen ENDFUNCTION.

Page 22: How to Integrate xMII Templates in the SAP PI Sheet...How to Integrate xMII Templates in the SAP PI Sheet Applies to: Brower-based PI sheet (SAP application component PP-PI-PMA-PMC)

How to Integrate xMII Templates in the SAP PI Sheet

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com © 2007 SAP AG 22

Copyright

© Copyright 2007 SAP AG. All rights reserved.

No part of this publication may be reproduced or transmitted in any form or for any purpose without the express permission of SAP AG. The information contained herein may be changed without prior notice.

Some software products marketed by SAP AG and its distributors contain proprietary software components of other software vendors.

Microsoft, Windows, Outlook, and PowerPoint are registered trademarks of Microsoft Corporation.

IBM, DB2, DB2 Universal Database, OS/2, Parallel Sysplex, MVS/ESA, AIX, S/390, AS/400, OS/390, OS/400, iSeries, pSeries, xSeries, zSeries, z/OS, AFP, Intelligent Miner, WebSphere, Netfinity, Tivoli, Informix, i5/OS, POWER, POWER5, OpenPower and PowerPC are trademarks or registered trademarks of IBM Corporation.

Adobe, the Adobe logo, Acrobat, PostScript, and Reader are either trademarks or registered trademarks of Adobe Systems Incorporated in the United States and/or other countries.

Page 23: How to Integrate xMII Templates in the SAP PI Sheet...How to Integrate xMII Templates in the SAP PI Sheet Applies to: Brower-based PI sheet (SAP application component PP-PI-PMA-PMC)

How to Integrate xMII Templates in the SAP PI Sheet

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com © 2007 SAP AG 23

Oracle is a registered trademark of Oracle Corporation.

UNIX, X/Open, OSF/1, and Motif are registered trademarks of the Open Group.

Citrix, ICA, Program Neighborhood, MetaFrame, WinFrame, VideoFrame, and MultiWin are trademarks or registered trademarks of Citrix Systems, Inc.

HTML, XML, XHTML and W3C are trademarks or registered trademarks of W3C®, World Wide Web Consortium, Massachusetts Institute of Technology.

Java is a registered trademark of Sun Microsystems, Inc.

JavaScript is a registered trademark of Sun Microsystems, Inc., used under license for technology invented and implemented by Netscape.

MaxDB is a trademark of MySQL AB, Sweden.

SAP, R/3, mySAP, mySAP.com, xApps, xApp, SAP NetWeaver, and other SAP products and services mentioned herein as well as their respective logos are trademarks or registered trademarks of SAP AG in Germany and in several other countries all over the world. All other product and service names mentioned are the trademarks of their respective companies. Data contained in this document serves informational purposes only. National product specifications may vary.

These materials are subject to change without notice. These materials are provided by SAP AG and its affiliated companies ("SAP Group") for informational purposes only, without representation or warranty of any kind, and SAP Group shall not be liable for errors or omissions with respect to the materials. The only warranties for SAP Group products and services are those that are set forth in the express warranty statements accompanying such products and services, if any. Nothing herein should be construed as constituting an additional warranty.

Page 24: How to Integrate xMII Templates in the SAP PI Sheet...How to Integrate xMII Templates in the SAP PI Sheet Applies to: Brower-based PI sheet (SAP application component PP-PI-PMA-PMC)

How to Integrate xMII Templates in the SAP PI Sheet

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com © 2007 SAP AG 24

These materials are provided “as is” without a warranty of any kind, either express or implied, including but not limited to, the implied warranties of merchantability, fitness for a particular purpose, or non-infringement.

SAP shall not be liable for damages of any kind including without limitation direct, special, indirect, or consequential damages that may result from the use of these materials.

SAP does not warrant the accuracy or completeness of the information, text, graphics, links or other items contained within these materials. SAP has no control over the information that you may access through the use of hot links contained in these materials and does not endorse your use of third party web pages nor provide any warranty whatsoever relating to third party web pages.

Any software coding and/or code lines/strings (“Code”) included in this documentation are only examples and are not intended to be used in a productive system environment. The Code is only intended better explain and visualize the syntax and phrasing rules of certain coding. SAP does not warrant the correctness and completeness of the Code given herein, and SAP shall not be liable for errors or damages caused by the usage of the Code, except if such damages were caused by SAP intentionally or grossly negligent.