sap mii alert and kpi management using adobe flex …

31
SAP MII Alert and KPI Management using Adobe Flex Technology Applies to: SAP MII release 12.0 or higher, Microsoft SQL Server 2000 or 2005 Summary Alert and Key Performance Indicator (KPI) Management are central tasks in any Manufacturing execution environment. This article contains a framework, which provides the code and projects to manage these two tasks in a SAP MII installation. The user interface is built in Adobe Flex technology. The article will as well show you how to build your own Adobe Flex applications on top of SAP MII. Download source files. Authors: Stephan Boecker and Salvatore Castro Company: SAP Created on: 20 November 2008 Author Bio Stephan Boecker works as a Director in Solution Management for MII. Salvatore Castro is a Solution Architect in Solution Management for MII. SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com © 2008 SAP AG 1

Upload: others

Post on 08-Nov-2021

3 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: SAP MII Alert and KPI Management using Adobe Flex …

SAP MII Alert and KPI Management using Adobe Flex Technology

Applies to: SAP MII release 12.0 or higher, Microsoft SQL Server 2000 or 2005

Summary Alert and Key Performance Indicator (KPI) Management are central tasks in any Manufacturing execution environment. This article contains a framework, which provides the code and projects to manage these two tasks in a SAP MII installation. The user interface is built in Adobe Flex technology. The article will as well show you how to build your own Adobe Flex applications on top of SAP MII. Download source files.

Authors: Stephan Boecker and Salvatore Castro

Company: SAP

Created on: 20 November 2008

Author Bio Stephan Boecker works as a Director in Solution Management for MII.

Salvatore Castro is a Solution Architect in Solution Management for MII.

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com © 2008 SAP AG 1

Page 2: SAP MII Alert and KPI Management using Adobe Flex …

SAP MII Alert and KPI Management using Adobe Flex Technology

Table of Contents Introduction .........................................................................................................................................................3

Overview .........................................................................................................................................................3 Installation...........................................................................................................................................................3 Alert Management Application............................................................................................................................6

Alert Definition.................................................................................................................................................6 Permissions for alert definition........................................................................................................................9 Creation of alerts at runtime............................................................................................................................9 Alert Emails .....................................................................................................................................................9 Alert Watch list ..............................................................................................................................................11 Deleting of alerts ...........................................................................................................................................15

KPI Management Application ...........................................................................................................................16 KPI Definition ................................................................................................................................................16 KPI set definitions .........................................................................................................................................18 KPI view definitions .......................................................................................................................................19 Permissions for KPI definition .......................................................................................................................21 Creating values for KPIs at runtime ..............................................................................................................21 KPI Watch List...............................................................................................................................................21 KPI Watch List for Mobile applications..........................................................................................................23 Deleting KPI values.......................................................................................................................................23

Unit Management .............................................................................................................................................24 Using the example applications inside SAP MII projects .................................................................................25 Building your own SAP MI application using Adobe Flex technology ..............................................................26

Building blocks ..............................................................................................................................................26 Communication with SAP MII .......................................................................................................................27 Interaction by the framework.........................................................................................................................29 Debugging.....................................................................................................................................................29 Authentication ...............................................................................................................................................30 Authorization .................................................................................................................................................30 Logging .........................................................................................................................................................30

Copyright...........................................................................................................................................................31

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com © 2008 SAP AG 2

Page 3: SAP MII Alert and KPI Management using Adobe Flex …

SAP MII Alert and KPI Management using Adobe Flex Technology

Introduction

Overview

In manufacturing operations, the handling of alerts and key performance indicators (KPI) is a common task found in most SAP MII implementations. While these applications are not very broad in scope, there is no built-in support in SAP MII for a Alert or KPI management. Typically these applications are built from scratch at the local site using SAP MII visual components. This article focuses on providing a framework for Alert and KPI Management, which can be used generically at each site without the need for further development. In addition, the user interface is based on Adobe Flex technology instead of traditional SAP MII applets/swing controls to show how to use different UI technologies on top of SAP MII. Finally, we will walk you through a complete scenario to show you how to create your own Adobe Flex applications using SAP MII business logic, so you can either modify the existing applications or create your own, visually rich internet applications. The SAP MII projects and the complete source code, are attached

Installation To run the KPI and alert management applications you need to perform the following installation steps

• Unpack the file MPM.zip which is attached to this article into a folder of your choice

• Navigate to the MPM/XMII/actions folder. You will find two action block jar files:

o UME.jar creates an action block in the SAP MII workbench to read data from SAP User Management.

o MPMGeneric.jar contains an action block to perform a dynamic transaction call. A dynamic transaction call is a transaction call in the workbench, which allows you to specify the name of the transaction in the link editor. The usual SAP MII workbench transaction call only allows you to assign a transaction name at design time (i.e, in the workbench), not at runtime. Please note that this functionality will be part of the SAP MII 12.1 product.

• Upload these two action blocks to SAP MII using System Management -> Custom Actions

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com © 2008 SAP AG 3

Page 4: SAP MII Alert and KPI Management using Adobe Flex …

SAP MII Alert and KPI Management using Adobe Flex Technology

After successful upload, the MII workbench should show the following additional action blocks should appear in the Logic Editor Environment of the Workbench. If they do not close the workbench and clear your Java WebStart cache, then reopen the workbench:

SAP MPM Generic -> Call DynamicTransaction Call a transaction dynamically in link editor

SAP UME -> GetAllRolesInfo Retrieves a list of all roles managed by the local NetWeaver UME instance where MII is installed.

SAP UME -> GetRoleInfo Retrieves information about a single SAP MII role and user information for all SAP NetWeaver users associated with that role managed by the local NetWeaver UME instance where MII is installed.

SAP UME -> GetActualUserInfo Retrieves user information about ‘actual’ SAP MII user, which is the user running this transaction at runtime. The user information is managed by the NetWeaver UME instance where MII is installed.

SAP UME -> GetUserInfoFromLogon Retrieves detailed information about any SAP NetWeaver user with the specified logon name where MII is installed.

• Navigate to the MPM/XMII/projects folder. You’ll find two projects:

o SAP_MPM, which contains the sources for the application o SAP_MPM_Example, which contains examples in areas where customer transaction

input/changes are required

Upload these two projects to SAP MII using the System Management -> Projects menu path

After successful upload, the MII workbench should show the following additional projects:

• Navigate to the MPM/SQL/DB folder. You’ll find two files containing the data base structures for Microsoft SQL server. Use the Microsoft SQL server Enterprise Manager to attach the DB schema called ‘MPM’ via the menu All Tasks -> Attach Database, and selecting the file MPM_Data.mdf.

• Create a SAP MII Data Server SQL Type connection named ‘MPM’ which points to the MPM database created in the previous step.

o In order to create this connection verify that you have already uploaded the proper JDBC driver for your version of MS SQL server. For more information please see the SAP MII Help documentation on how to perform and troubleshoot this procedure (Hint: All error messages appear in the SAP NetWeaver Logs).

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com © 2008 SAP AG 4

Page 5: SAP MII Alert and KPI Management using Adobe Flex …

SAP MII Alert and KPI Management using Adobe Flex Technology

Your ServerURL may vary depending on the MSSQL version you are using; the above is for MSSQL 2000.

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com © 2008 SAP AG 5

Page 6: SAP MII Alert and KPI Management using Adobe Flex …

SAP MII Alert and KPI Management using Adobe Flex Technology

Alert Management Application In manufacturing operations, alerts and notifications are commonly used objects. They are typically needed to inform the user about problems/errors, or exceptions that occur during production. In the solution presented here, an alert is a simple object which has the following characteristics:

• It contains a name and timestamp to identify the problem

• It contains additional fields which allow to get more detailed information about the problem

• It contains links to MII web pages which allow a further drill down, or allow resolution of the problem

• It contains a status varying from ‘New’, to ‘In Process’, and to ‘Deleted’

Alert Definition

An administrative application is provided allowing you to define an alert starting from an overview of all existing alerts:

To launch the application as part of the SAP MII portal by configuring the role/user navigation in the SAP MII Navigation Services -> Navigation page using the following URL:

/XMII/CM/SAP_MPM/action.jsp?application=Alert&operation=AlertAdmin

For details on how to install the applications, please refer to the deployment section below.

In the application, each alert has a descriptive name/technical ID and displays the time and user of the last change.

Clicking on an alert will provide you with further details:

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com © 2008 SAP AG 6

Page 7: SAP MII Alert and KPI Management using Adobe Flex …

SAP MII Alert and KPI Management using Adobe Flex Technology

On the left side, you see the overview list. Below the list are the details of the alert you selected. It contains the ID, Description, and expiration time in hours of an alert. The expiration time indicates the time span after which the actual alert can safely be deleted. This allows the system to clean up old alerts automatically.

The transaction performing the clean-up is located in SAP_MPM/Alert/AlertInstanceDeletion/DeleteAlertInstances, and should be scheduled periodically and should be based on your business process. Please note that this automatic clean-up only applies to alerts that have been confirmed by a user and therefore do not describe an actual error situation anymore. The details of handling of actually raised alerts will be described in the section covering the ‘AlertWatchList’. In the example above, all alerts which are based on the ‘Operations alert’ example will be deleted anytime two hours after they have been confirmed by the responsible user.

The right hand side shows the user and role assignment.

User and role assignment is used to identify which users/roles will receive the alert. In our example, one individual user (I808120) is assigned to handle this alert, as well as all users with a role of ‘XMII Administrators’. You can assign new roles by selecting the role and pressing ‘Add’. You can also delete a role by marking it and pressing ‘Delete’. Note that the roles provided are your actual SAP MII roles. You can add an individual SAP MII user by entering the user Id in the text field and pressing ‘Add’. Note that user names will be checked against SAP MII. If you want to find user ID in your MI system, use the SAP NetWeaver user management application.

The lower part of the right hand side, displays the use of additional fields for further problem identification, as well as the use of follow-up actions, which are links to web pages and their descriptive texts.

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com © 2008 SAP AG 7

Page 8: SAP MII Alert and KPI Management using Adobe Flex …

SAP MII Alert and KPI Management using Adobe Flex Technology

The fields are pairs of names and values that are freely definable to fit your application needs. The example shows the two different types of links you can use. The first link navigates to a web page which is local on the MII server and part of an SAP MII workbench project called ‘SAP_MPM_Example’. The second is a link to any web page you might want to include. Note that the web page has to be built separately. The ‘Test’ button allows you to launch the URL to verify its correctness. In case you need to re-read the alert and its fields as part of the web page launched (e.g. in order to extract additional information for display), the ID of the alert has been added in the first link. The transaction, which will allow you to read the alert according to its ID, is included in the SAP MII workbench projects shipped as part of this article and called SAP_MPM/Alert/AlertDefinition/GetAlertDefinition.

When you finish editing, press ‘Save’ to store your settings. ‘Cancel’ will bring you back to the alert overview page, ‘Delete’ will delete the alert previously selected in the overview list.

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com © 2008 SAP AG 8

Page 9: SAP MII Alert and KPI Management using Adobe Flex …

SAP MII Alert and KPI Management using Adobe Flex Technology

Permissions for alert definition

In order to be able to define alerts, your SAP MII user must be part of a specific role called ‘MPMAdminRole’; this role is not defined in SAP NW User Management. You are part of this role, as long as one of your SAP MII roles is mapped to this ‘MPMAdminRole’. The mapping is carried out in a configuration XML file, which can be found in the SAP MII workbench project SAP_MPM/WEB/Configuration/MPMConfiguration.xml. The relevant section of this configuration XML should look similar to this:

In the example shipped, all members of the MII roles ‘XMII Administrators’ and ‘XMII Users’ are considered to be associated with the role ‘MPMAdminRole’, and therefore can access the Alert Definition page. Users who are not assigned to this role will receive an exception when trying to launch the Administration page.

Creation of alerts at runtime

The previous sections focused on the definition of an alert configuration which should be done by an administrator. In order to be useful, you still need a way to create an alert corresponding to an error situation during operation. The transaction to raise an alert is located in SAP_MPM/Alert/AlertInstanceCreation/CreateAlertInstance.

The only input parameter needed is the ID of the alert to be created and provides a perfect opportunity for integration with the Plant Connectivity (PCo) product (To released on Q1 ’09). The transaction will create the actual alert (alert instance) and if it is configured by end users can send out e-mails to inform assigned users about the new alert. Since this will trigger a transaction any action possible in the MII Transaction environment can be performed. Please note that a new alert will not be created if an alert with the same ID already exists and is not confirmed by users. The reason behind this is to reduce alarm chatter to end users by resending the exact same information repeatedly in case the alert is detected as part of a scheduled transaction. For details on alert confirmations, please refer to the section about ‘AlertWatchList’ below. The ‘AlertWatchList’ supplements the application that allows individual users to subscribe to receive emails about the various available alerts.

Alert Emails

Whenever alerts are created and users have configured their ‘AlertWatchList’ to receive email about alerts, notification e-mails will be sent out for each new alert. While typically email configuration will be up to your individual landscape, an example of such a transaction has been provided as part of SAP_MPM_Examle/Alert/SendAlertInformationViaEmail. You only need to adjust the mail server’s address and logon to be able to reuse this transaction. Please note that the email address of the recipient users does not need to be provided at all. Instead this information will be read automatically from the users’ setting in SAP NW User Management. If you change the example transaction and store it under you own name, you have to inform the Alert Management application about the new location of the transaction handling emails. This is done as part of the configuration file

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com © 2008 SAP AG 9

Page 10: SAP MII Alert and KPI Management using Adobe Flex …

SAP MII Alert and KPI Management using Adobe Flex Technology

SAP_MPM/WEB/Configuration/MPMConfiguration.xml which was discussed before. The relevant section is marked below:

Change the XML element’s value from its original setting of SAP_MPM_Examle/Alert/SendAlertInformationViaEmail to point to the path of your own transaction.

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com © 2008 SAP AG 10

Page 11: SAP MII Alert and KPI Management using Adobe Flex …

SAP MII Alert and KPI Management using Adobe Flex Technology

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com © 2008 SAP AG 11

Alert Watch list

The previous sections focused on the definition of an alert done by an administrator. After an alert has been raised, end users will can monitor and react to alerts via the Alert watch list.

You can launch the application based on roles/users from the SAP MII Navigation Services -> Navigation editor and setting the navigation link to use the following URL:

/XMII/CM/SAP_MPM/action.jsp?application=Alert&operation=AlertWatchList

The list of alerts a user receives is depending on his role or user name and correlates to the settings done in the alert definition application.

The overview list the time and date of last change to the alert, the actual status, the user who changed the

d alert, and an icon indicating additional messages associated with this alert. Please note that for system created alerts, the user field is initially empty. Clicking on an alert will show the additional information anfollow up actions as specified in the alert definition phase.

Nw

ow we’ll walk through the different options a user has to deal with the alert. Clicking on a follow-up action ill navigate to the web page or URL associated with the follow-up action. Clicking the ‘Process’ button will

indicate that the problem the alert represents is actually being worked on, and will change the status of the alert to ‘In Process’.

Page 12: SAP MII Alert and KPI Management using Adobe Flex …

SAP MII Alert and KPI Management using Adobe Flex Technology

At the same time, this status will prevent SAP MII to re-issue the same alert again if the problem has not been corrected by the time the system re-runs the previously defined alert creation transaction.

Pressing ‘Delete’ will mark the alert as closed. Alerts which are closed are not displayed as part of the watch list anymore. Please note that this status would allow SAP MI to re-issue the alert if the problem still persists. Clicking on ‘Cancel’ will return to the overview list. Finally, clicking on the ‘Forward’ button will allow the user to forward the alert via e-mail, including an additional message.

The overview list shows you additional buttons which allow you to work with the list. Pressing ‘Settings’ will open a popup window, in which you can specify if you want to receive new alerts via e-mail. Please note that this setting is user-specific and is a requirement for receiving e-mail notifications for new alerts.

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com © 2008 SAP AG 12

Page 13: SAP MII Alert and KPI Management using Adobe Flex …

SAP MII Alert and KPI Management using Adobe Flex Technology

The ‘History’ button is only available to administrative users, which have the permissions to perform alert definitions. ‘History’ will allow you to track all alerts, their status changes, and all comments associated with that alert.

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com © 2008 SAP AG 13

Page 14: SAP MII Alert and KPI Management using Adobe Flex …

SAP MII Alert and KPI Management using Adobe Flex Technology

This includes alerts with a status of ‘Closed’ which are not displayed at all in the alert watch list. This tracking functionality will allow administrative users to see which user changed the status of any alert, and when. The ‘AutoRefresh’ button in the overview list allows you to toggle between ‘auto refresh’ and ‘no auto refresh’. If auto refresh is enabled the page will automatically update every 3 minutes to check for new alerts and if it is not then the page behaves like a traditional web page.

Finally, each alert in the overview list has an icon indicating that any comments have been posted with the alert. Clicking on this icon will open a popup where you can see all existing comments and add your own by clicking the ‘Save’ button.

Please note that the icon changes if a message exists.

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com © 2008 SAP AG 14

Page 15: SAP MII Alert and KPI Management using Adobe Flex …

SAP MII Alert and KPI Management using Adobe Flex Technology

Deleting of alerts

Alerts are deleted automatically by the system if:

• The alert has a status of ‘Closed’ which corresponds to having used the ‘Delete’ button in the alert watch list

• The alert has expired according to the expiration time in the alert definition

In order to perform this, schedule transaction SAP_MPM_Examle/Alert/AlertInstancedeletion/DeleteAlertInstances periodically at your convenience.

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com © 2008 SAP AG 15

Page 16: SAP MII Alert and KPI Management using Adobe Flex …

SAP MII Alert and KPI Management using Adobe Flex Technology

KPI Management Application

Key performance indicators are used to track operational entities and their values over time with respect to a target value. Our solution provides a framework to define and monitor any KPI based on a value you assign via an SAP MII transaction.

You launch the application by configuring the following URL in the Navigation Services -> Navigation page:

/XMII/CM/SAP_MPM/action.jsp?application=KPI&operation=KPIAdmin

KPI Definition

Follows has similar design as the Alerting Framework; KPI management provides an administrative application, which allows the definition of a KPI. Launching the application will provide you with an overview list of all of the defined KPIs:

Note that there a three tabs which allow you to define the three basic components for KPIs

• A tab to manage KPIs as basic values to be monitored

• A tab to manage KPI sets, where a KPI set is a new KPI built from other KPIs. A usage example would be that you group several KPIs into a KPI set to monitor a complete plant area with a single derived KPI

• A tab to manage views. In a view, you assign KPIs and KPI sets to users or roles in the SAP MII system

Clicking on a KPI in the overview list in the first tab will show the details of that KPI opening in the lower part of the screen.

Now we’ll walk through how to define a KPI which has the following properties:

• A unique ID identifying the KPI technically. In our example we simply used ‘Kpi1’

• A description which will be presented to end users. That is usually the name of the KPI, such as ‘LineAvailability’ or – as in our example – ‘First Kpi’.

• An expiration period in days. When monitoring KPIs, a KPI will receive many different values over the time period that it is monitored. Values that are older than this expiration period can be deleted automatically by SAP MII.

• A target value and unit of measure for the KPI.

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com © 2008 SAP AG 16

Page 17: SAP MII Alert and KPI Management using Adobe Flex …

SAP MII Alert and KPI Management using Adobe Flex Technology

• A number and percentage deviation to identify a trend in the KPI. This functionality is provided to allow you to define when a consecutive set of values is indicating a trend such as ‘improving values’ or ‘deteriorating values’. Trends are displayed visually (see KPI watch list) and allow you to take action on a KPI before its value reaches a critical limit. In the two input fields displayed, you enter the number of values and the deviation in percent at which you want to indicate that this is a trend. In our example it would read as follows: ‘If the last 4 values of my KPI ‘First Kpi’ show a deviation of 10 percent or more from the target value of 100 Bars, I want SAP MII to indicate this as a trend.’ Deviations lower than 10 percent will be considered fluctuations and will not change the trend. The tendency of the trend (improving, deteriorating) depends on the values and is assigned automatically by SAP MII

• A URL showing more details for a KPI. This URL will be available to users of the ‘KPI watch list’ to perform drill downs. Similar to the alert definition you can use an absolute URL (like http://www.sap.com) or a URL relative to the SAP MII server path (as shown in the example above). Clicking the ‘Test’ button will allow you to launch the web page. Building this web page is up to you

• A definition of a KPI type. The application distinguishes three types o ‘Fixed Value’. A KPI of this type should be close to the target value. Positive and negative

deviations will be considered. Example is a calibrated machine for which you don’t want any deviations.

o ‘Lower values allowed’. This KPI considers only positive deviations. Examples are cost related KPIs for which you are only concerned about high values

o ‘Higher values allowed’. This KPI considers only negative deviations. Examples are revenue related KPIs, where you are only concerned about low values

• A set of limits which defines the status of the KPI. The set of limits changes for each KPI type. For example, in a KPI of type ‘Lower values allowed’, you only have to specify upper limits, since all lower values will have a status of ‘green’ as default. In the example above for the type ‘Fixed Value’, you have to specify a status for lower and upper limits. Note that the values for each set have to be strictly descending or ascending. The status changes from green to red using a 5-point scale.

• A connection to the alerting module, which allows you to create alerts for specific KPI situations. If you defined alerts before, you can use them here. The section allows you to raise an alert on two conditions:

o A KPI changes a status to a specific value. For example, you can raise an ‘Operational alert’ whenever your KPI reaches a ‘Light red’ status, as shown above. Once the alert is triggered by the system, the usual alert processing (email notifications, watch list, etc.) will be triggered as well.

o Triggering the alert based on your own, more complex processes. In this case the system leaves the determination of whether or not the value of the KPI warrants an alert up to you. You enter any transaction in the input field ‘Use transaction’.

The example provided is the transaction

SAP_MPM_Example/KPI/KPIDefinition/Interfaces/TriggerNewAlertForKPI. Use this transaction as copy reference since the transaction parameters have to follow this example to be usable. There is an input parameter containing the ID of the KPI. You can use this parameter to perform additional reading of KPI values to determine if this is an alert situation. The only output parameter allowed is a Boolean flag called ‘CreateAlert’. If you return it as ‘true’ (‘1’), the alert will be created, otherwise not. Clicking the ‘Test’ button allows you to verify that your transaction can be processed successfully.

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com © 2008 SAP AG 17

Page 18: SAP MII Alert and KPI Management using Adobe Flex …

SAP MII Alert and KPI Management using Adobe Flex Technology

The output contains the typical SAP MII response structure, where a single row contains the parameter ‘Result’. In this example the value is ‘1’, which indicates you want the alert raised.

Pleas note that this check for alerts is performed each time a new KPI value is received by the application. The SAP MII project. SAP_MPM/KPI contains all necessary queries to read any historic value of a KPI in the subprojects KPIHistory, KPIWatchList, and KPIInstanceCreation so you get a clear decision point on the need to create an alert.

The interaction buttons ‘New’, ‘Cancel’, and ‘Delete’ provide the same functionality as in the alert case.

KPI set definitions

KPI sets are accessible from the second tab in the KPI administration. The overview list displays the existing KPI sets, clicking on an entry will display its details in the lower screen area.

As a KPI, a KPI set has a technical ID, description, performance trend, and details URL. However it does not contain a value, status or alert. Instead you combine several KPIs, which are listed under ‘KPIs Available’ to the ‘KPI Set Components’ using arrow buttons. You can assign a weight factor to determine how much the underlying KPI contributes to the KPI set. In this example, the new KPI set is comprised of two KPIs: ‘First Kpi’ and ‘Second ‘Kpi’, where the second one has three times the weight of the first one. Note the following rules for KPI sets are based on this composition:

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com © 2008 SAP AG 18

Page 19: SAP MII Alert and KPI Management using Adobe Flex …

SAP MII Alert and KPI Management using Adobe Flex Technology

• The status of the KPI set is equal to the worst status of any of its dependent KPIs.

• Since a KPI set can combine KPIs with different units, a KPI set does not have its own target value or unit.

• The trend of a KPI set is the weighted average of the trend of the underlying KPIs. The weight factors are the ones used in the KPI set definition.

The interaction buttons ‘New’, ‘Cancel’, and ‘Delete’ provide the same functionality as for KPIs.

KPI view definitions

A KPI view combines KPIs and KPI sets, and associates them with a user or role. Users using the KPI Watch List (see below) can access the views associated with them and monitor the underlying KPIs. Management of KPI views is accessible form the third tab (“Manage Views’).

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com © 2008 SAP AG 19

Page 20: SAP MII Alert and KPI Management using Adobe Flex …

SAP MII Alert and KPI Management using Adobe Flex Technology

Clicking on an entry will display details in the lower screen area.

Analogous to KPIs and KPI sets, a View has a technical ID and a description. In addition, it contains a list of KPIs or KPI sets under ‘KPIs Used’, which can be assigned from the list of all available KPIs and KPI sets shown as ‘KPIs Available’. In the upper part of the screen, you see examples for user/role assignments. In this example, every user that is part of the ‘XMII Administrators’ role will see this view, as will user ‘I808120’.

The interaction buttons ‘New’, ‘Cancel’, and ‘Delete’ provide the same functionality as for KPIs.

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com © 2008 SAP AG 20

Page 21: SAP MII Alert and KPI Management using Adobe Flex …

SAP MII Alert and KPI Management using Adobe Flex Technology

Permissions for KPI definition

The concept for permissions for KPI management is identical to the one used in Alert Management. If you have the role of MPMAdministrator as associated in the configuration file, you can perform KPI Management, otherwise you will receive an error when you launch the application.

Creating values for KPIs at runtime

The values for KPIs are set at runtime based on your queries or transactions through which you get the KPI value. To fill KPI values, you use transaction SAP_MPM/KPI/KPIInstanceCreation/CreateKPIValue. The transaction takes as input value the ID of the KPI, whose value you want to record, and the value. That is all which is needed from your side. The framework will store the KPI, calculate status, trends, alerts, etc.

KPI Watch List

Similar to alerting, end users monitor KPIs in the KPI watch list. Set the following URL in the Navigation Services -> Navigation screen:

/XMII/CM/SAP_MPM/action.jsp?application=KPI&operation=KPIWatchList

The watch list displays each user’s list of views associated with his/her role or user name.

Clicking the ‘Go’ Button will display all KPIs and KPI sets, which are combined in this view. The ‘Default’ link can be used to set a user-specific view as the default view. Once a default view has been set, the KPI watch list will launch the default view and display all its KPIs and KPI sets when the application starts.

The KPI watch list looks as follows:

The KPI watch list displays the status, the KPI the target and actual (=most recent) value, and the absolute difference. The name of the KPI is displayed as a hyperlink pointing to the URL/SAP MII web site you specified in the definition. The performance gap is a percentage deviation, but it considers the KPI type, not just the KPI values.

For example, if a KPI has a type of ‘Lower values allowed’ for a target value of 100, a value of 95 would show a performance gap of 0%, not 5%. This is due to the fact that this gap evaluates how your KPI is doing with respect where you want it to be, not just purely form a numeric perspective. Since you specified that values lower than 100 are perfectly fine, there is no performance gap. A value of 105 would show the expected gap of 5%.

The example above displays a performance gap of 5%, since this KPI is of type ‘Fixed’ which means, that all deviations affect the performance. Please note that, according to this logic, a performance gap can never be negative. The trend is either flat, pointing up, or down. Also note that the trend uses the same logic as explained for performance gaps. An upward tend does not mean that the last values of the KPI are simply rising; it indicates that your KPI is improving from its desired value. Clicking on the trend icon will display the history of the KPI values, including target, actual, and threshold values in form of a classical SAP MII line chart (Similar to the Limit Chart.

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

Page 22: SAP MII Alert and KPI Management using Adobe Flex …

SAP MII Alert and KPI Management using Adobe Flex Technology

The web page for the history can be found in the Web tab under: SAP_MPM/KPI/History/KPIHistory.irpt and SAP_MPM/KPI/History/IndexKPIHistory.irpt This will provide the history for all of the KPI sets.

In the KPI Watch list, the timestamp column in the overview list displays the time of the last change. Similar to the Alert watch list, the KPI watch list allows comments to be added to a KPI, so other users can share additional information about the KPI.

This example also indicates the difference between a KPI (first line), and a KPI set (second line). A KPI set can be expanded to show all underlying KPIs. The KPI set’s status is red, due to the fact that at least one of the underlying KPIs has a red status. It does not contain a target or actual value, but has its own trend which takes the weight factors of the KPIs into consideration. Clicking on the ‘±’ icon will expand the list

Finally, the ‘Auto refresh’ toggle performs the same use as in the alert watch list. Whenever new values are recorded, they will be shown without the need to perform a browser refresh.

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

Page 23: SAP MII Alert and KPI Management using Adobe Flex …

SAP MII Alert and KPI Management using Adobe Flex Technology

KPI Watch List for Mobile applications

A smaller version of the KPI watch list is available for use in web browser enabled mobile devices that support java script. Please refer to the SAP MII Mobile Device Configuration guide referenced from the MII SDN Wiki for additional information.

You launch this application by using the following URL in the Navigation Services -> Navigation page and configuring a mobile theme with the following links: /XMI/XMII/CM/SAP_MPM/KPI/MobileKPIWatchList.irpt?ViewId=<ViewId>,in which <ViewId> is a placeholder for an existing technical ID of a view you have already created.

You can find the mobile web application as part of the SAP MII workbench in the project SAP_MPM/KPI under the WEB tab.

Deleting KPI values

As with alerts, you can schedule a transaction to delete KPI values that are considered to be outdated according to the definition of the KPI. Use transaction SAP_MPM/KPI/KPIInstanceDeletion/DeleteKPIOutdatedKPIValues.

Please note that comments entered in the KPI watch list also expire with an expiration period of four times the one used for the underlying KPI. If needed, change this setting in queries: SAP_MPM/KPI/KPIInstanceDeletion/GET_EXPIRED_KPI_INSTANCE_COMMENTS and SAP_MPM/KPI/KPIInstanceDeletion/GET_EXPIRED_INDEX_KPI_INSTANCE_COMMENTS

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

Page 24: SAP MII Alert and KPI Management using Adobe Flex …

SAP MII Alert and KPI Management using Adobe Flex Technology

Unit Management Units used in KPIs are provided as a separate application for the following reason: you might already have your own unit management in place. In addition, management of units is usually a cross-application task, which should not be bundled with a specific application.

You launch the application as part of the SAP MII portal by using the URL:

/XMII/CM/SAP_MPM/action.jsp?application=General&operation=MPMAdmin

As before, clicking on an entry will display its details in the lower screen area and allow you to change the unit.

Each unit has a technical ID and a text, which will be presented to the user. In our examples, we have chosen the ISO code of the unit as the ID. The buttons ‘Save’, ’Cancel’, and ‘Delete’ work in the exact same way as in the previous management applications.

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

Page 25: SAP MII Alert and KPI Management using Adobe Flex …

SAP MII Alert and KPI Management using Adobe Flex Technology

Using the example applications inside SAP MII projects You can build Adobe Flex application components via an SDK, or by using Adobe Flex builder, which comes as an Eclipse plug-in or a standalone software component. Adobe Flex uses its own ‘Action Script’ language for developing code. The Adobe Flex application itself is a user interface which contains a set of controls and Action Script code for layout/interaction. A wide variety of UI components are available and can be assembled freely to get the layout desired.

The result of any build process for your Adobe Flex application is a .swf file. This file can be uploaded into the WEB subdirectory of your SAP MII project. The .swf file is then incorporated into an .html page. Environments such as Adobe Flex Builder contain the necessary basic html code to perform this plug in of a .swf file.

You can also use open source Java Script wrappers such as ‘swfobject’. The swfobject.js library is used in our examples, and attached in SAP_MPM/WEB/js. At runtime, the SAP MII web page will be launched and your browser will display the embedded Flex application. In addition, we provide our own Flash variables which contain the SAP MII server and port information. This information is needed (inside the Flex application) to call back to SAP MII transactions and to fill and interact with UI controls. Please refer to the section on building an application for more details about this process. We performed the following steps:

1. Create a basic header.jsp page, which extracts the server and port information from the incoming request. The page can be found in the SAP_MPM/WEB directory.

2. Create a directory structure grouping web pages in terms of areas (Alert,KPI).

3. Create a basic action.jsp page, which serves as primitive page controller. The page can be found

as well in the SAP_MPM/WEB directory. action.jsp simply forwards to any target .jsp page using a <jsp:forward> tag. Forwarding is controlled by two additional request parameters called ‘application’ and ‘operation’ resulting in a forward to <application>/<operation.jsp>. ‘Application’ matches the areas created in the previous step. Please note that we used this forwarding technique in the example applications before: Calling the ‘KPIWatchList’ is performed by calling the page controller and forwarding to the application KPI and operation KPIWatchList as in /XMII/CM/SAP_MPM/action.jsp?application=KPI&operation=KPIWatchList.

4. Create the ‘operation.jsp’ (e.g., KPIAdmin.jsp) page in the directory structure above, together with the .swf file. It will use the server and port parameters extracted in the header.jsp page, and provide those as input to the Adobe Flex application by means of the swfobject.js library. A typical call to plug-in a .swf file is shown below:

<script type="text/javascript"> // <![CDATA[ var so = new SWFObject("/XMII/CM/SAP_MPM/KPI/KPIAdmin.swf","KPIAdmin", "100%", "100%", "9", "#E0E0E0"); so.addParam("quality", "high");

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com © 2008 SAP AG 25

Page 26: SAP MII Alert and KPI Management using Adobe Flex …

SAP MII Alert and KPI Management using Adobe Flex Technology

so.addVariable("Server","<%=(String)request.getAttribute("com.sap.xmii.mpm.server")%>"); so.addVariable("Port","<%=(String)request.getAttribute("com.sap.xmii.mpm.port")%>"); so.write("flashcontent"); // ]]> </script>

The SWFObject(…) contains the path to the .swf file and the name of the Flex application. SAP MII server parameters are added as variables. The so.write method will write the plug-in code in the web page.

Building your own SAP MI application using Adobe Flex technology

Building blocks

Our main building blocks for Adobe Flex applications are as follows:

• Each application (e.g., AlertAdmin) is part of a Adobe Flex project

• UI controls, which are used by several applications, are part of a ‘CommonUI’ project. The same is used for classes in several applications, grouped in ‘Common’.

• ‘Images’ contains assets used in applications.

• MPMFramework is the main library handling the communication to SAP MII.

Each Flex application references projects/libraries needed as part of its build path.

Please note that the sources for all of these projects are attached in the source/Flex folder of the attached MPM.zip file.

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com © 2008 SAP AG 26

Page 27: SAP MII Alert and KPI Management using Adobe Flex …

SAP MII Alert and KPI Management using Adobe Flex Technology

Communication with SAP MII

The ‘MPMFramework’ uses an HTTP connection to the ‘Runner’ service in SAP MII to trigger business logic transactions. In order to use the framework in a request/response cycle, you have to perform the following steps:

1. Start with an event in your Flex application. This can either be some user-riggered interaction, or a generic event like the ‘initialize’ event for the application. In your action script code, write an event handler method for this event. In this method, use the framework class RequestHandlerBase to create a new instance of a class implementing IRequestHandler.

Next, create a new instance of UIRequest, which allows you to feed the request with parameters from your Flex application. An example passing in parameters is shown below, where a parameter is entered as a name/value pair in the form of a Param instance.

Finally, call the handleRequest method. This creates and executes a basic HTTP request.

2. Build your own logic for this request/response in an instance of a class implementing IConcreteViewHandler. In the screenshot above, the class UserViewsHandler is an example of such an implementation. The responsibility of this class is to server as gateway to SAP MII. You have to provide the following methods:

a. A getter for the name of the business logic transaction you want executed on SAP MII, called TransactionName():String.

b. A getter for the primitive input parameters you want to supply, called ServiceInputParameters():Array. If the transaction does not need input parameters, return null.

c. A getter for the parameter holding an XML payload as input parameter for complex inputs, called InputParameterXML():ServiceXMLParameter. ServiceXMLParameter is a name/XML pair. If the transaction does not need complex XML input parameters, return null.

d. A getter for the name of the output parameter containing the response XML document, called OutputParameterName():String. Please note that the framework expects your transaction to return an XML response.

e. A method called processRequestInput(request:UIRequest). This method is the first one called by the framework. In this method you can check the parameters handed over in the UIRequest shown in the previous step. You can also perform additional parameter settings to map to the SAP MII transaction input. An example of just forwarding a simple input parameter could look like this:

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com © 2008 SAP AG 27

Page 28: SAP MII Alert and KPI Management using Adobe Flex …

SAP MII Alert and KPI Management using Adobe Flex Technology

A more complex example passing input parameters and a complex XML structure would

look as follows:

The example source code contains many examples. They can be found inside each

application project in the viewhandler sections.

f. A method called processResponse(request:UIRequest,result:XML). This method is called when a successful SAP MII response is received by the framework. In the method parameters you receive the resulting XML stream from SAP MII. Use this method to update your user interface according to the result received. Please note that your class has a reference to the Flex application available in the attribute parent, created when your class was instantiated. A simple example, where the response is checked to be a valid ‘Illuminator’ document and used as data provider for a grid, would look as follows:

For more details, refer to the source code attached.

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com © 2008 SAP AG 28

Page 29: SAP MII Alert and KPI Management using Adobe Flex …

SAP MII Alert and KPI Management using Adobe Flex Technology

Interaction by the framework

This section gives you a short overview of the activities done by the framework and their sequence. You can use this information to adapt the framework, or debug problems you might encounter. A request/response cycle works as follows

1. Called by the Flex application, the class RequestHandlerBase creates an instance of RequestHandler using the implementation of IConcreteViewHandler provided by the Flex application in the event hander (see example above).

2. The method handleRequest is called with an input parameter of type UIRequest (see example above).

3. The framework calls the processRequestInput method on the IConcreteViewHandler as described above to check the UIRequest for completeness. If errors occur, processing will stop here.

4. The framework looks up a static SessionManager, which contains the connection parameter to the SAP MII server. If the instance does not exist, it is instantiated as a Singleton object. Please note that this is the point in time when the server and port, which was set when the flex application was plugged into a web page, comes into play.

5. The framework builds an HTTP request to the SAP MII ‘Runner’ service using the parameters provided by the getter methods in IConcreteViewHandler.

6. The framework executes the request and registers itself as listener for the response.

7. Once the response comes in, the method receiveResponse(result:XML)is processed. Here the framework checks that the response document is any of the valid XML return documents issued by an SAP MII server. If so, it calls the processResponse method in the IConcreteViewHandler described above, and hands over the response XML document.

8. Control returns to the Flex application.

Debugging

In order to facilitate debugging of your application in Flex builder without the need to import your .swf file into SAP MII, you have to programmatically provide logon credentials to SAP MII as part of your request. Please note that you only have to do this during your development, not for your final deployment. The class ServiceLocatorn provides a convenient method, called addLogonInfo(service:HTTPService), where you can provide a user/password combination to log on during development. The method is commented out in the source file shipped with the package.

Note: Make sure you comment this line back to how you received it, before you finally import the resulting .swf file into your SAP MII project. Inside the SAP MII environment, every user, who logs on to the SAP MII web page hosting your .swf file, will receive a logon ticket as part of his browser session. This makes the need for a specific logon as part of the method above unnecessary. If, in addition, you perform any checks on user roles (for example) as part of your SAP MII transactions, you need the identify of the logged on user to be propagated through the Flex application to the SAP MI transaction. Using the logon ID you provided during development will lead to wrong results.

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com © 2008 SAP AG 29

Page 30: SAP MII Alert and KPI Management using Adobe Flex …

SAP MII Alert and KPI Management using Adobe Flex Technology

Authentication

As described in the previous section, .swf files, which are embedded in SAP MII web pages, will forward the

SAP logon ticket to the SAP MII transaction. There is no separate authentication taking place as part of the

Flex application.

Authorization Typically, you want to restrict user access to particular parts of your Flex application by providing role-based access. The example applications in this package distinguish between administrative access, where an administrator configures applications, and the default user, which uses the corresponding watch lists. The checking of roles is taking place as part of the first SAP MII transaction called for each Flex application. In the return XML document, a logical flag is incorporated, which indicates successful authorization or not. In order to do this as part of a SAP MII transaction, additional action blocks have been provided, which allow you to look up roles and verify user settings. Please refer to the installation section on how to do this. The Flex application itself should not provide a separate authorization scheme of its own.

Logging As a convenience, the ‘MPMFramework’ enables you to perform application logging inside your Adobe Flex application, where your logs will appear as part of the J2EE engine logging framework. The advantage of using the J2ee engine logging framework is that all logging takes place in the same place used by administrators and support personnel. Please look at the IConcreteViewHandler implementations as part of the example applications to find out how to issue a log statement. The default log severity is set to ‘ERROR’ which means that all log message of type ‘error’ or a higher severity will be logged. If you want to change the setting, you can pass a new parameter called ‘LogLevel’ to the Flex application in the same way you forwarded the server name and port. Allowed values for ‘LogLevel’ are (in increasing severity levels) as follows:

• DEBUG

• INFO

• WARNING

• ERROR

• FAILURE As usual, a log level will log all messages with a severity at least as high as the log level’s own severity.

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com © 2008 SAP AG 30

Page 31: SAP MII Alert and KPI Management using Adobe Flex …

SAP MII Alert and KPI Management using Adobe Flex Technology

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com © 2008 SAP AG 31

Copyright © 2008 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, System i, System i5, System p, System p5, System x, System z, System z9, z/OS, AFP, Intelligent Miner, WebSphere, Netfinity, Tivoli, Informix, i5/OS, POWER, POWER5, 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.

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.

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.