building mobile apps with sap mii and sybase unwired platform...the agent instance will transfer...

42
Building Mobile Apps with SAP MII and Sybase Unwired Platform The Mobile KPI Monitor Applies to SAP Manufacturing Integration and Intelligence (SAP MII) Version12.2 (http://help.sap.com/mii ) SAP Plant Connectivity 2.2 (http://help.sap.com/pco ) Sybase® Unwired Platform 2.1 (http://www.sybase.com/products/mobileenterprise/sybaseunwiredplatform ) Summary The white paper shows how to build mobile KPI apps for smartphones on data collected from the shop floor by SAP Plant Connectivity (PCo) solution, processed by the SAP Manufacturing Integration and Intelligence (MII) solution, and finally transferred to mobile devices by the Sybase Unwired Platform. The reader will gain insight into integrating different SAP solutions for manufacturing industries as well as enterprise mobility with the end objective of building industry- specific mobile apps for the on-the-go decision makers. Authors: Arne Schramm (SAP Research) Martin Knechtel (SAP Research) Houssame Mohammed Hajji (SAP Research) Anirban Majumdar (SAP Research) Company: SAP AG Created on: 10 September 2012

Upload: others

Post on 26-Jul-2021

6 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Building Mobile Apps with SAP MII and Sybase Unwired Platform...The agent instance will transfer monitored data from the Matrikon Simulation Server (the source system) to the MII solution

Building Mobile Apps with SAP MII and Sybase Unwired Platform The Mobile KPI Monitor

Applies to

SAP Manufacturing Integration and Intelligence (SAP MII) Version12.2 (http://help.sap.com/mii) SAP Plant Connectivity 2.2 (http://help.sap.com/pco) Sybase® Unwired Platform 2.1 (http://www.sybase.com/products/mobileenterprise/sybaseunwiredplatform)

Summary

The white paper shows how to build mobile KPI apps for smartphones on data collected from the

shop floor by SAP Plant Connectivity (PCo) solution, processed by the SAP Manufacturing

Integration and Intelligence (MII) solution, and finally transferred to mobile devices by the Sybase

Unwired Platform. The reader will gain insight into integrating different SAP solutions for

manufacturing industries as well as enterprise mobility with the end objective of building industry-

specific mobile apps for the on-the-go decision makers.

Authors: Arne Schramm (SAP Research)

Martin Knechtel (SAP Research)

Houssame Mohammed Hajji (SAP Research)

Anirban Majumdar (SAP Research)

Company: SAP AG

Created on: 10 September 2012

Page 2: Building Mobile Apps with SAP MII and Sybase Unwired Platform...The agent instance will transfer monitored data from the Matrikon Simulation Server (the source system) to the MII solution

Copyright/Trademark

Table of Contents Architecture Overview..................................................................................................................................... 3

SAP Pco and MII Configuration ...................................................................................................................... 4

Overview of PCo ................................................................................................................................................ 4 Configuring PCo ................................................................................................................................................ 4 Overview of SAP MII ........................................................................................................................................ 14 Configuring SAP MII ........................................................................................................................................ 14 Sybase Unwired Platform Introduction ....................................................................................................... 27

Platform Overview ........................................................................................................................................... 27 Application Types ............................................................................................................................................ 27 Further Information .......................................................................................................................................... 28 Sybase Unwired Platform Installation ......................................................................................................... 28

Runtime Installation ......................................................................................................................................... 28 SDK Installation ............................................................................................................................................... 28 Sybase Unwired Platform Mobile Business Objects Development .......................................................... 29

Web Service Mobile Business Object .............................................................................................................. 29 Customization (Personalization key, synchronization parameter and query) ................................................. 30 Deployment and Code generation ................................................................................................................... 32 Sybase Unwired Platform Mobile App Development ................................................................................. 33

Web service MBO’s data retrieval ................................................................................................................... 33 Apple Push Notification service (APNs) .......................................................................................................... 34 Final configuration steps .................................................................................................................................. 36

Page 3: Building Mobile Apps with SAP MII and Sybase Unwired Platform...The agent instance will transfer monitored data from the Matrikon Simulation Server (the source system) to the MII solution

Copyright/Trademark

INTRODUCTION Using SAP Manufacturing Integration and Intelligence (SAP MII) you can directly connect your shop-floor systems with your enterprise business systems. You can integrate all production data in real time, including orders, material, equipment states, costs or product quality. Based on that production data you can – among other things - calculate KPIs relevant to your production. With a mobile application, consuming these KPIs, line workers, foremen or plant managers can easily get an overview on the KPIs in their responsibility. They can also get notifications in case a KPI reaches a defined threshold (critical or warning state), so that they can react in time. In the following sections, we briefly explain the overall architecture for a mobile application consuming data from SAP MII. We will then show exemplarily how transactions in MII can be used to compile KPIs based on the raw shop floor data. Before we provide a step-by-step tutorial on installing and configuring the platform, we will give a short introduction on Sybase Unwired Platform, explaining the different application types supported including best practices when to use which functionality. We will conclude by explaining how you can finally build and deploy your own iPhone app using the API generated by Sybase Unwired Platform. ARCHITECTURE OVERVIEW

The high level architecture for the mobile KPI Monitor is depicted in Figure 1. The shop floor data, coming from disparate business and manufacturing systems, is integrated via SAP MII. Based on this data, relevant KPIs are calculated and stored in a KPI-History database for further reference. Sybase Unwired Platform is retrieving this data using a web-service interface and delivers it to the mobile application upon request. If a KPI, calculated in SAP MII crosses a defined threshold, a push notification is sent via Sybase Unwired Platform to the Mobile KPI Monitor, so that a user gets aware of the situation even if he/she is not working with his phone at the moment.

Figure 1: Architecture Overview

Page 4: Building Mobile Apps with SAP MII and Sybase Unwired Platform...The agent instance will transfer monitored data from the Matrikon Simulation Server (the source system) to the MII solution

Copyright/Trademark

SAP PCO AND MII CONFIGURATION

Overview of PCo The SAP Plant Connectivity (PCo) solution provides real-time event notification capabilities from plant systems to backend SAP applications through a push model. It enables query execution capabilities against plant manufacturing systems (i.e. read/write values) and can be deployed as a highly extensible plant connectivity infrastructure on which on which manufacturing applications can be build. Some key concepts of PCo are defined below: Source System: Connection configuration used to connect to a Plant system Destination System: Connection configuration used to connect to an SAP system Agent Instance: A user-defined application / process based on the installed Agent type that delivers real-time event notifications based on plant activity. Notification: A user-defined complex event that is the result of: (a) state-change events from single items, as in OPC Data Access; (b) complex event subscriptions, as in OPC Alarms and Events; (c) [optionally] applying triggering rules; (d) defining the Notification data structure; and (e) generating and delivering the Notification Message to Destination(s) Subscription: It is some object (simple or complex) in the plant system you want to monitor. A subscription item can be a simple value, such as temperature, pressure, and time or a complex item, such as an OPC A&E Notification. Configuring PCo

Start SAP Plant Connectivity

1. Double click on PCo Management Console Shortcut to start PCo:

Add a source system

The source system will establish a connection to a data source like a programmable logic controller, OPC server, databases, etc.

1. Click on the “Add Source System” button (highlighted)

Page 5: Building Mobile Apps with SAP MII and Sybase Unwired Platform...The agent instance will transfer monitored data from the Matrikon Simulation Server (the source system) to the MII solution

Copyright/Trademark

2. Choose OPC DA Agent from the “Source System Type” combo box

3. Give it a name

4. Click OK

o The popup disappears and a configuration pane shows up at the right.

5. Click on the combo box (highlighted) and select localhost OR click on refresh button

o A list of available OPC Server appears.

6. Select available entry MatrikonOPC Server for Simulation and Testing DA 3.00. For this particular example, we extract simulated KPI values from a Matrikon OPC server which you can download from http://www.matrikonopc.com. For the rest of the example, four KPI values are simulated all having the numerical type “Real”: OEE, LeadTime, ScrapValue, and Throughput.

7. Click Save button to save the source system configuration

o The save button will be disabled once the configuration is saved.

Page 6: Building Mobile Apps with SAP MII and Sybase Unwired Platform...The agent instance will transfer monitored data from the Matrikon Simulation Server (the source system) to the MII solution

Copyright/Trademark

Add a destination system

The destination system will establish a connection to a target system (SAP MII)

8. Click on the “Add Source System” button under “Destination Systems”

o A popup to create a destination connection shows up

9. Choose MII Destination from the “Type” combo box

10. Give it a name

11. Click OK

o The popup disappears and a configuration pane shows up at the right.

12. Fill out the server properties: server name, port, version, user name, password for connecting to the destination MII deployment (contact your administrator if you are unsure of the log in details)

13. Click Save button to save the destination configuration

o The save button will be disabled once the configuration is saved.

Page 7: Building Mobile Apps with SAP MII and Sybase Unwired Platform...The agent instance will transfer monitored data from the Matrikon Simulation Server (the source system) to the MII solution

Copyright/Trademark

Add an agent instance

The agent instance will transfer monitored data from the Matrikon Simulation Server (the source system) to the MII solution (the destination system). In our scenario we are going to subscribe to variables of the source system. If a value of a variable changes, PCo will be notified and it has to decide when it should send a notification to the destination system.

14. Click on the Add Agent Instance button in the PCo Management Console

15. Choose the source system from the “Source System” combo box that you created

16. Give it a name

17. Click OK

o The popup disappears and a configuration pane shows up at the right.

18. Configure the agent instance

a. Tick the checkbox Run Host as an Executable

b. Leave the other values untouched

Page 8: Building Mobile Apps with SAP MII and Sybase Unwired Platform...The agent instance will transfer monitored data from the Matrikon Simulation Server (the source system) to the MII solution

Copyright/Trademark

19. Switch to Subscription Items tab

20. Click Browse button

o A popup opens up where we can browse the source system for variables that we want to subscribe to.

21. Click Browse button

o The inner pane will show a tree with variables of the configured source system.

Page 9: Building Mobile Apps with SAP MII and Sybase Unwired Platform...The agent instance will transfer monitored data from the Matrikon Simulation Server (the source system) to the MII solution

Copyright/Trademark

22. Navigate to the element AddressRoot/Configured Aliases

23. Select the four KPI names: OEE, ScrapValue, LeadTime, and Throughput

24. Click add Selected Item button

25. Click OK button

o The popup will be closed

Page 10: Building Mobile Apps with SAP MII and Sybase Unwired Platform...The agent instance will transfer monitored data from the Matrikon Simulation Server (the source system) to the MII solution

Copyright/Trademark

26. Switch to Tag Query tab

27. Select Cache from the Cache Mode combo box

28. Click on the Add Notification button in the Agent Instances pane

29. Choose the agent instance from the “Agent Instance Name” combo box that you created

30. Give it a name

31. Click OK

o The popup disappears and a configuration pane shows up at the right.

32. Leave the trigger tab untouched. Here you could basically define an expression that is evaluated on each data change of the subscribed variable. The result of the evaluation is used to decide whether a notification will be send to the target system or not.

33. Switch to Output tab. Here you can define how the message to be sent by PCo to the destination will look like.

34. Click Add Expression button in the main pane

o A popup shows up.

Page 11: Building Mobile Apps with SAP MII and Sybase Unwired Platform...The agent instance will transfer monitored data from the Matrikon Simulation Server (the source system) to the MII solution

Copyright/Trademark

Select the variable you have browsed from the Subscription Item combo box

a. Please make sure that the item name appears in the expression text area

35. Click OK button

o The popup disappears and the chosen variable appears inside of the Output tab. After configuring all the KPI values from Matrikon, the configuration will look like

36. Click OK button

Page 12: Building Mobile Apps with SAP MII and Sybase Unwired Platform...The agent instance will transfer monitored data from the Matrikon Simulation Server (the source system) to the MII solution

Copyright/Trademark

37. Switch to Destination tab. I this tab you have to assign the target system where PCo will deliver the messages.

38. Click the Add Destination System button

o A popup will show up.

39. Choose the destination system from the “Destination System Type” combo box that you have created

40. Give it a name

41. Click OK

o The message box will disappear and the created entry will appear in the left pane of the destination tab.

Page 13: Building Mobile Apps with SAP MII and Sybase Unwired Platform...The agent instance will transfer monitored data from the Matrikon Simulation Server (the source system) to the MII solution

Copyright/Trademark

42. Expand the recently created destination entry

43. Select Destination. (this will browse the configured MII for available functions /transactions)

b. On the right pane a list of folders appears

44. Select Persistency folder (or any other folder you have created to input the KPI values from PCo)

c. This will browse the folder for transactions

45. Select the StoreAllKPI transaction (or any other transaction you have created to input the KPI values from PCo)

d. In the bottom of the Destination tab a Transaction Name will appear.

46. Select the entry KPIValue from the “Input Parameter Name” combo box

o SAP PCo is now configured

47. Save the whole configuration Menu: Plant Connectivity -> Save All

48. Select the created Agent Instance and click the green play button to start the Agent Instance

Page 14: Building Mobile Apps with SAP MII and Sybase Unwired Platform...The agent instance will transfer monitored data from the Matrikon Simulation Server (the source system) to the MII solution

Copyright/Trademark

Overview of SAP MII

SAP MII provides a direct connection between shop-floor systems and business operations. It ensures that all data that affects manufacturing is visible in real time – including information about orders, materials, equipment status, costs, and product quality. With SAP MII, one can build composite applications combining different data sources and transactional systems. Furthermore, data can be evaluated and condensed before being forwarded to the destination system(s). The solution provides functionalities to combine synchronous and asynchronous messaging and at the same time compare data (and KPI) with thresholds and generate alarms. The SAP MII Workbench is a toolbox to compose complex transactions utilizing predefined actions. It provides a visual editor to compose processes which can be use to map disparate data structures and sources. An overview of the workbench is shown below:

Configuring SAP MII

Start SAP MII Portal and Workbench

1. Log in to MII with your credentials in the user management screen as shown below:

Page 15: Building Mobile Apps with SAP MII and Sybase Unwired Platform...The agent instance will transfer monitored data from the Matrikon Simulation Server (the source system) to the MII solution

Copyright/Trademark

2. Before starting the SAP MII Workbench, you have to create database tables to store and retrieve temporary KPI values passed on from SAP PCo

Click Data Services on the MII Portal menu and then select Data Servers. The intention is to create a database named „KPIDB‟ as shown below

The details for the KPIDB are the following

Using the SAP SQL Studio or command line, create a table for storing KPI values received from SAP PCo. In our example, the table “KPI_SIM1” stores the KPI values and has the following configuration.

This table will be reference in the MII transactions.

Make sure that the KPIDB database is running under MII data services.

3. Next, start the SAP MII Workbench from the MII Portal

Page 16: Building Mobile Apps with SAP MII and Sybase Unwired Platform...The agent instance will transfer monitored data from the Matrikon Simulation Server (the source system) to the MII solution

Copyright/Trademark

The Workbench is a Java Web Start Application, running on your desktop.

Create a folder for storing relevant transactions for this particular scenario. In the running example, the “Persistency” folder in the SAP MII Workbench stores transactions as shown below:

4. From the menu, select File -> New -> SQLQuery and name it “storeValue”. Double-click to open the Template Category „Data Source‟.

Select the available server as the database you just created (in our example KPIDB) and select the mode as “Command”. This step is illustrated in the next screenshot.

Page 17: Building Mobile Apps with SAP MII and Sybase Unwired Platform...The agent instance will transfer monitored data from the Matrikon Simulation Server (the source system) to the MII solution

Copyright/Trademark

Next click „Fixed Query Details‟ and you will see a screen below. Under „Available Tables‟ you will see the list of all tables you have created in the running database KPIDB as explained previously. In our example, we will define a static query on the table „KPI_SIM1‟. Once you select the table name you will see the available columns on the right.

Write the fixed query “UPDATE KPI_SIM1 SET "VALUE" = (CASE ID WHEN 1 THEN [Param.1] WHEN 2 THEN [Param.2] WHEN 3 THEN [Param.3] WHEN 4 THEN [Param.4] END) WHERE ID IN ('[Param.5]', '[Param.6]', '[Param.7]', '[Param.8]')” in the editor as shown.

Essentially this query updates „KPI_SIM1‟ table columns based on incoming KPI name. For instance, if the KPI name is „LeadTime‟ then the corresponding real-time value is updated in the column „VALUE‟. MII provides a way of referencing column names in tables through named

Page 18: Building Mobile Apps with SAP MII and Sybase Unwired Platform...The agent instance will transfer monitored data from the Matrikon Simulation Server (the source system) to the MII solution

Copyright/Trademark

parameters. Details of configuring and using these parameters can be found in the SAP MII documentation. In our example, the parameters are configured by selecting „Parameters‟ from the Template Categories as shown below.

Parameters 5 though 8 assign KPI IDs whereas parameters 1 through 4 assign dummy values to the „VALUE‟ column corresponding to the KPIs. These would be replaced with incoming real-time values coming from SAP PCo. The mapping of KPI name to IDs would be shown later in the next steps.

Now let us use this SQLQuery in a transaction. Create a new transaction and name it “StoreAllKPI”.

Double click the transaction and open the configuration pane.

Page 19: Building Mobile Apps with SAP MII and Sybase Unwired Platform...The agent instance will transfer monitored data from the Matrikon Simulation Server (the source system) to the MII solution

Copyright/Trademark

Next from the „Actions‟ below, choose „Data Queries -> SQL Query‟ and drag it to the transaction box.

Double click SQL_Query_0 to open a popup window with the name „Action Properties‟ as shown below.

Click „Configure Object‟ to open another popup window with the name „Query Configuration‟ as shown below. Choose the Query Template as storeValue under the Persistency folder which you created in the previous step. Assign two named parameters: Param.1 and assign it a default value 5 (corresponding to the KPI ID) and Param.2 and assign it a default value „OEE‟ (corresponding to KPI Name).

Page 20: Building Mobile Apps with SAP MII and Sybase Unwired Platform...The agent instance will transfer monitored data from the Matrikon Simulation Server (the source system) to the MII solution

Copyright/Trademark

Next, go back to the „Action Properties‟ popup window and click „Configure Links‟. Another popup window named „Link Editor‟ shows up.

The Link Editor is crucial for performing the mapping from KPI Names to their corresponding IDs and then storing the KPI values by invoking the SQL query on KPI_SIM1 table.

We will map the incoming KPI Names and IDs to the named parameters in the „Link Editor‟. Click the „Incoming‟ tab and drill down to Transaction -> KPIValue -> Notificationmessage -> Header -> Body -> Values.

Page 21: Building Mobile Apps with SAP MII and Sybase Unwired Platform...The agent instance will transfer monitored data from the Matrikon Simulation Server (the source system) to the MII solution

Copyright/Trademark

Click KPI Name „LeadTime‟ and drop on to „Param.1‟ on the right. This will automatically create the expression „Transaction.KPIValue{/NotificationMessage/Body/Values/LeadTime}‟ in the „Expression‟ editor. This mapping ensures that real-time KPI value for „LeadTime‟ is mapped to Param.1 for updating the table „KPI_SIM1‟ in database KPIDB. Similarly, map OEE to Param.2 ScrapValue to Param.3 Throughput to Param.4 After assigning KPI values, map KPI Names to IDs for the SQL Case query in „storeValue‟ to work. Map LEADTIME_ID to Param.5 OEE_ID to Param.6 SCRAPVALUE_ID to Param.7 THROUGHPUT_ID to Param.8

This completes the configuration of „StoreAllKPI‟ transaction. It is now ready to take KPI values

from SAP PCo, invoke the SQL Query „storeValue‟, and store real-time results to the table „KPI_SIM1‟. Check whether the configuration of the parameters for the transaction is correct by right clicking on „StoreAllKPI‟ and selecting Test and Execute. If you have configured correctly, the following popup will show.

Page 22: Building Mobile Apps with SAP MII and Sybase Unwired Platform...The agent instance will transfer monitored data from the Matrikon Simulation Server (the source system) to the MII solution

Copyright/Trademark

5. Now that we have configured the transaction for storing all real-time KPI values to the „KPI_SIM1‟ table, we will show how to create transaction to retrieve the latest value and make it available to Sybase Unwired Platform via web service.

Create a new SQLQuery from the Workbench menu and name it „SelectKPI‟

For the created SQLQuery, select „KPIDB‟ as the data server. This will be reflected in the editor pane on the right.

Select „Fixed Query Details‟ and enter the fixed SQL Query “Select "KPI", "VALUE", "UNIT", "THRESHOLD", "MAX_VAL", "MIN_VAL", "DESCR" from KPI_SIM1 Where "KPI"=[Param.1]”

Page 23: Building Mobile Apps with SAP MII and Sybase Unwired Platform...The agent instance will transfer monitored data from the Matrikon Simulation Server (the source system) to the MII solution

Copyright/Trademark

This simple query returns a row set with KPI attributes where the KPI name matches the named parameter „Param.1‟.

The next step is to initialize „Param.1‟ with a default value. Select „Parameters‟ from the Template Categories panel and set the Param.1 default value to „LEADTIME‟. This will be replaced with the corresponding KPI name passed on through the web service call from the Sybase Unwired Platform as explained in the next section.

6. The next step is to create an MII transaction which calls the SQLQuery „SelectKPI‟ during runtime.

Create a new transaction from the Workbench menu and name it „GetKPI. Double click on „GetKPI‟ to open the action configuration panel on the right.

As before, insert a Data Query action SQL Query in the „GetKPI‟ transaction block. The resulting configuration will look like the following figure.

Page 24: Building Mobile Apps with SAP MII and Sybase Unwired Platform...The agent instance will transfer monitored data from the Matrikon Simulation Server (the source system) to the MII solution

Copyright/Trademark

Next double click the SQL Query action „SQL_Query_0‟ to configure it. A configuration popup will appear as shown below.

Click „Configure Object‟ and assign the „SelectKPI‟ SQL Query to this action block. The Query Template will therefore indicate „Persistency/SelectKPI‟ corresponding to the folder location where the SQL Query „SelectKPI‟ is located.

Page 25: Building Mobile Apps with SAP MII and Sybase Unwired Platform...The agent instance will transfer monitored data from the Matrikon Simulation Server (the source system) to the MII solution

Copyright/Trademark

Also, add a parameter name „Param.1‟ and assign it a default value, such as „LEADTIME‟. When Sybase Unwired Platform calls this transaction, „Param.1‟ would carry the KPI name from the web service.

Now go back and click „Configure Links‟. Under the „Incoming‟ tab, add an expression „"'"&Transaction.KpiName&"'"‟ to „Param.1‟. Note the quotes and ampersands before and after the expression which are required for MII to correctly parse the KPI name input string from web service and assign it to „Param.1‟.

Now select the „Outgoing‟ tab and assign the query results, returned as a rowset, to the „output‟ xml element of the web service message that is returned to Sybase Unwired Platform.

Page 26: Building Mobile Apps with SAP MII and Sybase Unwired Platform...The agent instance will transfer monitored data from the Matrikon Simulation Server (the source system) to the MII solution

Copyright/Trademark

Test the transaction „GetKPI‟ by right clicking the transaction name.

If the transaction and links are correctly configured, you will get the following message when the transaction is test executed.

7. Save all the created transactions from the SAP MII Workbench menu. You have now successfully configured MII and ready to configure Sybase Unwired Platform.

Page 27: Building Mobile Apps with SAP MII and Sybase Unwired Platform...The agent instance will transfer monitored data from the Matrikon Simulation Server (the source system) to the MII solution

Copyright/Trademark

SYBASE UNWIRED PLATFORM INTRODUCTION

Platform Overview The Sybase Unwired Platform (http://infocenter.sybase.com/help/index.jsp) connects arbitrary backend systems like databases, web-services or other software applications with mobile devices. The platform consists of a Sybase Unwired Platform Runtime and a Sybase Mobile SDK. The Runtime supports deploying, managing and running mobile applications, while the SDK brings a set of development tools used to build mobile applications. Application Types The platform enables you to build mobile applications that access your enterprise business processes, systems, data and information wherever you are. It supports online as well as offline applications. Online applications are typically ad hoc in nature and often used to lookup certain data available in the backend systems. An example for online applications is a lookup of customers. Offline applications are more heavyweight and provide access to information independent of connectivity. This allows users to perform complex tasks, e.g. a sales process, even if they are offline. The Sybase Mobile SDK supports three kinds of applications, Native Object API Applications, HTML5/JS Hybrid Applications and OData SDK Applications. Figure 2 shows the typical choice of application types depending on the online/offline scenario.

Figure 2 Sybase Unwired Platform Application Types

Native Object API Applications

If users need to work offline and data should be synchronized when connected again later, a native object API application using mobile business objects (MBO) has to be developed. It can be fully customized using the mobile devices native libraries. HTML5/JS Hybrid Applications For hybrid applications a container is developed and deployed, containing one or more workflow applications. These applications also use MBOs to synchronize with backend systems. The workflow apps, however, support more simple business processes following a request-response pattern. OData SDK Applications The SAP NetWeaver® Gateway aims to ease the consumption of SAP business process and data by non-SAP systems and technologies. It therefore uses the RESTful OData protocol to make the data available. The platform supports the consumption of this data with OData SDK applications which basically connect through the Unwired Server and SAP Gateway to SAP enterprise information systems. There is no synchronization mechanism for these applications.

Page 28: Building Mobile Apps with SAP MII and Sybase Unwired Platform...The agent instance will transfer monitored data from the Matrikon Simulation Server (the source system) to the MII solution

Copyright/Trademark

Further Information A very good documentation explaining all Sybase Unwired Platform 2.1 fundamentals can be found here: http://infocenter.sybase.com/help/topic/com.sybase.infocenter.dc01204.0210/doc/html/title.html The complete documentation of Sybase Unwired Platform 2.1 covering all functionality in detail can be found here: http://infocenter.sybase.com/help/topic/com.sybase.infocenter.pubs.docset-SUP-2.1.0/doc/html/title.html SYBASE UNWIRED PLATFORM INSTALLATION

Runtime Installation

1. From the directory containing the install files e.g., sup0210… run the setup file and follow the Sybase Unwired Platform installation wizard.

2. Select the un-served license. 3. License product edition: Personal development and License Type is SS: Standalone Seat License.

Number of client licenses depends on the number chosen while creating the license. SDK Installation

From the directory run the setup file and follow the installation wizard.

Page 29: Building Mobile Apps with SAP MII and Sybase Unwired Platform...The agent instance will transfer monitored data from the Matrikon Simulation Server (the source system) to the MII solution

Copyright/Trademark

SYBASE UNWIRED PLATFORM MOBILE BUSINESS OBJECTS DEVELOPMENT

Here is the link to the Sybase tutorial we began with before jumping into the code part http://infocenter.sybase.com/help/index.jsp?topic=/com.sybase.infocenter.dc01213.0210/doc/html/mqu1264543829068.html. The tutorial provides the explained steps to build a basic application synchronizing database records to an iPhone mobile application mentioning crucial information to the smooth running of the application. It is strongly advised to follow this tutorial. Before creating a web service Mobile Business Object, a Mobile Application Project must be created following these steps:

1. Open the Sybase Unwired Workspace by clicking on the icon in the desktop with the same name. 2. Under File New, click on Mobile Application Project. 3. Name your project and click on finish. 4. The main panel holds the Mobile Application Diagram. Right click in the latter, go to Switch

Developer Profile and select Advanced. Web Service Mobile Business Object

In Sybase Unwired Workspace, under Enterprise Explorer (left panel, second from the top), right click Web Services then “new”. Name then give the URL‟s web service.

Right click “connect” on the just created web service.

Drag and drop the targeted method into the Mobile Application Diagram.

Select “Attributes” then OK.

In the definition screen, Click on the XSLT line and press Edit.

Select the radio button “Define XSLT manually” and paste the Annex 3 XSLT script.

Press OK then Next.

In the Parameters screen fill in the Default value for loginName and loginPassword, as you defined in the MII installation above, e.g. loginName= mii_adm, loginPassword= Initial1.

Page 30: Building Mobile Apps with SAP MII and Sybase Unwired Platform...The agent instance will transfer monitored data from the Matrikon Simulation Server (the source system) to the MII solution

Copyright/Trademark

Customization (Personalization key, synchronization parameter and query) The general solution to access a Web service with an input parameter was described here: http://mobility-internal.sybase.com/questions/9385/sup21-and-web-service-call-with-native-app . These steps are as the following:

Add a personalization key: from the workspace navigator, under YourProject right click on Personalization Keys -> New -> Personalization Key.

Name the presonalization key, which type is String, is nullable, is <NULL> and stored in “Server”.

Page 31: Building Mobile Apps with SAP MII and Sybase Unwired Platform...The agent instance will transfer monitored data from the Matrikon Simulation Server (the source system) to the MII solution

Copyright/Trademark

Select the MBO. Go to the panel under the Mobile Application Diagram and select “Properties” tab.

Select Synchronization, add a synchronization parameter by clicking on add.

Rename your parameter under Parameter Name and under Personalization Key select the personalization key created earlier.

Uncheck the Nullable check box.

Under the MBO‟s Properties tab Attributes Load Parameters, open “inputParams” variable then

click on “KpiName” Synchronization Parameter cell.

Page 32: Building Mobile Apps with SAP MII and Sybase Unwired Platform...The agent instance will transfer monitored data from the Matrikon Simulation Server (the source system) to the MII solution

Copyright/Trademark

Fill in this cell with the created synchronization parameter. This synchronization parameter will let you change the parameters used to retrieve data from the MBO.

Create a query under Properties tab Attributes Object Queries Add

Define the query‟s name: “findbykpi”.

Add a parameter and map it to the “KPI” attribute.

Change the return type to “Return a single object”.

Deployment and Code generation Deployment

Right click “deploy project” in the Mobile Application Diagram window.

Select “message based” and go ahead with the default settings.

In “Server Connection Mapping” screen, click on the Server connection tab and select “New server connection”.

Page 33: Building Mobile Apps with SAP MII and Sybase Unwired Platform...The agent instance will transfer monitored data from the Matrikon Simulation Server (the source system) to the MII solution

Copyright/Trademark

In the “Create New Server Connection” screen press OK.

Hit next then finish.

Code generation

Right click “Generate code” in the Mobile application Diagram window.

Proceed with the default selection for the first 2 screens.

Under “Configure options” screen specify: Language: Objective C. Platform: iOS. Unwired server: My Unwired Server (or the chosen server while following “Deployment” section).

Go ahead and select finish keeping the other options as preconfigured. SYBASE UNWIRED PLATFORM MOBILE APP DEVELOPMENT

Web service MBO’s data retrieval

The following lines of code enable the web service call: MKPIM_PersonalizationParameter *pp = [MKPIM_MKPIMDB getPersonalizationParameters];

[pp setPk_kpi:kpiName];

[pp save];

The following line of code enables the web service response retrieval, using the query “findbykpi” we defined above in the Sybase Unwired Workspace: MKPIM_Xacute *xl = [MKPIM_Xacute findbykpi:kpiName]; The detailed source code for initiating the Web service call with parameter and retrieving the results

Page 34: Building Mobile Apps with SAP MII and Sybase Unwired Platform...The agent instance will transfer monitored data from the Matrikon Simulation Server (the source system) to the MII solution

Copyright/Trademark

taking them over into the local data model of the iPhone KPI Monitor app is provided in Annex 1.

Apple Push Notification service (APNs) Before starting this section, here is the apple page concerning push notifications: http://developer.apple.com/library/mac/#documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/ApplePushService/ApplePushService.html Developer and push certificate

Register into the apple developer website with the enterprise account.

Request the apple push certificate.

Once the push certificate received, install it into your keychain under login.

Export the production certificate into a “.p12“ file. Xcode

Add the lines of code in the Annex 2 to the “AppDelegate” class of your XCode project. The code tells your Sybase Unwired Platform server that the app is able to receive push notifications.

Sybase control center (SCC)

Please see here: http://infocenter.sybase.com/help/index.jsp?topic=/com.sybase.infocenter.dc01205.0210/doc/html/aba1259709684708.html for a complete description of how to configure the Sybase Unwired Platform server for the Apple Push Notification Service. Copy the exported “.p12” certificate to the hard disk with the Sybase Unwired Platform installation: UnwiredPlatform_InstallDir\Servers\MessagingServer\bin\. Then in the SCC, navigate to Servers Server configuration Messaging Apple push configuration and add a new configuration with the following characteristics:

Application Name: the name under the Xcode project Targets Build Settings Product name

Select “Use existing certificate”.

Enter the certificate password (defined during the exportation).

Enter the Apple Push Notification servers (gateway.push.apple.com:2195 and feedback.push.apple.com:2196). Make sure that your network configuration allows contacting those servers on the specified ports. You might consider using a TCP forwarder with a local network address, as we did in the following screenshot.

Page 35: Building Mobile Apps with SAP MII and Sybase Unwired Platform...The agent instance will transfer monitored data from the Matrikon Simulation Server (the source system) to the MII solution

Copyright/Trademark

Page 36: Building Mobile Apps with SAP MII and Sybase Unwired Platform...The agent instance will transfer monitored data from the Matrikon Simulation Server (the source system) to the MII solution

Final configuration steps

iDevice settings

Set the ServerNameSetting to be Sybase Unwired Platform´s relay server. If you do not use a relay server, put the Sybase Unwired Platform server and make sure it can be reached from the iPhone‟s network.

CompanyIDSetting changes from 0 to the company id you set in your relay server, e.g. “store”. If you do not use a relay server, leave it unchanged.

Insert the user name and activation code settings you configured in your SCC.

SCC settings

Details for the push notifications, including the message displayed on the iPhone etc. can be configured in the SCC. For this purpose navigate to Applications Application Connections select your user Properties Apple Push Notifications. The dialog might be filled as in our following screenshot.

Page 37: Building Mobile Apps with SAP MII and Sybase Unwired Platform...The agent instance will transfer monitored data from the Matrikon Simulation Server (the source system) to the MII solution

Copyright/Trademark

Page 38: Building Mobile Apps with SAP MII and Sybase Unwired Platform...The agent instance will transfer monitored data from the Matrikon Simulation Server (the source system) to the MII solution

Copyright/Trademark

Annexes:

Annex 1 Add to the “AppDelegate” class the following:

NSArray *kpiNames = [NSArray arrayWithObjects:@"OEE", @"LEADTIME", @"THROUGHPUT", @"SCRAPVALUE", nil]; for (NSString *kpiName in kpiNames) { MKPIM_PersonalizationParameters *pp = [MKPIM_MKPIMDB getPersonalizationParameters]; [pp setPk_kpi:kpiName]; [pp save]; while ([MKPIM_MKPIMDB hasPendingOperations]) [NSThread sleepForTimeInterval:0.2]; MKPIM_Xacute *xl = [MKPIM_Xacute findByKPI:kpiName]; KPI* kpi = [[KPI alloc] init]; [kpi setName:xl.KPI]; [kpi setActual:[xl.VALUE doubleValue]]; [kpi setTarget:[xl.THRESHOLD doubleValue]]; [kpi setUnit:xl.UNIT]; [kpi setLowRedYellow:[xl.MIN_VAL doubleValue]]; [kpi setHighYellowRed:[xl.MAX_VAL doubleValue]]; [kpi setDefinition:xl.DESCR]; [kpiArray addObject:kpi]; } [self.tableView reloadData];

Page 39: Building Mobile Apps with SAP MII and Sybase Unwired Platform...The agent instance will transfer monitored data from the Matrikon Simulation Server (the source system) to the MII solution

Copyright/Trademark

Annex 2

At the end of “-(void)applicationDidFinishLaunching:(UIApplication *)application” method, in the “AppDelegate” class add:

[[UIApplication sharedApplication] registerForRemoteNotificationTypes: (UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert)]; Then add in the “appdelegate” class the following methods:

-(void)application:(UIApplication *)app didRegisterForRemoteNotificationsWithDeviceToken: (NSData *)devToken { MBOLogInfo(@"In did register for Remote Notifications:%@", devToken);

[SUPPushNotification setupForPush:app]; [SUPPushNotification deviceTokenForPush:app deviceToken:devToken]; } -(void)application:(UIApplication *)app didFailToRegisterForRemoteNotificationsWithError: (NSError *)err { MBOLogError(@"Error in registration. Error: %@", err); } -(void)application:(UIApplication *)app didReceiveRemoteNotification:(NSDictionary *) userInfo { MBOLogInfo(@"In did receive Remote Notifications", userInfo); }

Page 40: Building Mobile Apps with SAP MII and Sybase Unwired Platform...The agent instance will transfer monitored data from the Matrikon Simulation Server (the source system) to the MII solution

Copyright/Trademark

Annex 3

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:ns1="http://www.sap.com/xMII"> <xsl:template match="//ns1:XacuteResponse"> <data> <Record> <Field op_label="KPI" op_position="1" op_datatype="STRING" op_nullable="true">KPI</Field> <Field op_label="VALUE" op_position="2" op_datatype="STRING" op_nullable="true">VALUE</Field> <Field op_label="UNIT" op_position="3" op_datatype="STRING" op_nullable="true">UNIT</Field> <Field op_label="THRESHOLD" op_position="4" op_datatype="STRING" op_nullable="true">THRESHOLD</Field> <Field op_label="MAX_VAL" op_position="5" op_datatype="STRING" op_nullable="true">MAX_VAL</Field> <Field op_label="MIN_VAL" op_position="6" op_datatype="STRING" op_nullable="true">MIN_VAL</Field> <Field op_label="DESCR" op_position="7" op_datatype="STRING" op_nullable="true">DESCR</Field> </Record> <Record> <Field> <xsl:attribute name="op_label">KPI</xsl:attribute> <xsl:attribute name="op_position">1</xsl:attribute> <xsl:attribute name="op_datatype">STRING</xsl:attribute> <xsl:attribute name="op_nullable">true</xsl:attribute> <xsl:value-of select="ns1:Rowset/ns1:Row/ns1:KPI" /> </Field> <Field> <xsl:attribute name="op_label">VALUE</xsl:attribute> <xsl:attribute name="op_position">2</xsl:attribute> <xsl:attribute name="op_datatype">STRING</xsl:attribute> <xsl:attribute name="op_nullable">true</xsl:attribute> <xsl:value-of select="ns1:Rowset/ns1:Row/ns1:VALUE" /> </Field> <Field> <xsl:attribute name="op_label">UNIT</xsl:attribute> <xsl:attribute name="op_position">3</xsl:attribute> <xsl:attribute name="op_datatype">STRING</xsl:attribute> <xsl:attribute name="op_nullable">true</xsl:attribute> <xsl:value-of select="ns1:Rowset/ns1:Row/ns1:UNIT" /> </Field> <Field> <xsl:attribute name="op_label">THRESHOLD</xsl:attribute> <xsl:attribute name="op_position">4</xsl:attribute> <xsl:attribute name="op_datatype">STRING</xsl:attribute> <xsl:attribute name="op_nullable">true</xsl:attribute> <xsl:value-of select="ns1:Rowset/ns1:Row/ns1:THRESHOLD" /> </Field> <Field> <xsl:attribute name="op_label">MAX_VAL</xsl:attribute> <xsl:attribute name="op_position">5</xsl:attribute>

Page 41: Building Mobile Apps with SAP MII and Sybase Unwired Platform...The agent instance will transfer monitored data from the Matrikon Simulation Server (the source system) to the MII solution

Copyright/Trademark

<xsl:attribute name="op_datatype">STRING</xsl:attribute> <xsl:attribute name="op_nullable">true</xsl:attribute> <xsl:value-of select="ns1:Rowset/ns1:Row/ns1:MAX_VAL" /> </Field> <Field> <xsl:attribute name="op_label">MIN_VAL</xsl:attribute> <xsl:attribute name="op_position">6</xsl:attribute> <xsl:attribute name="op_datatype">STRING</xsl:attribute> <xsl:attribute name="op_nullable">true</xsl:attribute> <xsl:value-of select="ns1:Rowset/ns1:Row/ns1:MIN_VAL" /> </Field> <Field> <xsl:attribute name="op_label">DESCR</xsl:attribute> <xsl:attribute name="op_position">7</xsl:attribute> <xsl:attribute name="op_datatype">STRING</xsl:attribute> <xsl:attribute name="op_nullable">true</xsl:attribute> <xsl:value-of select="ns1:Rowset/ns1:Row/ns1:DESCR" /> </Field> </Record> </data> </xsl:template> </xsl:stylesheet>

Page 42: Building Mobile Apps with SAP MII and Sybase Unwired Platform...The agent instance will transfer monitored data from the Matrikon Simulation Server (the source system) to the MII solution

Copyright/Trademark

COPYRIGHT

© Copyright 2012 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, Excel, Outlook, and PowerPoint are registered trademarks of Microsoft Corporation.

IBM, DB2, DB2 Universal Database, System i, System i5, System p, System p5, System x, System z, System z10, System z9, z10, z9, iSeries, pSeries, xSeries, zSeries, eServer, z/VM, z/OS, i5/OS, S/390, OS/390, OS/400, AS/400, S/390 Parallel Enterprise Server, PowerVM, Power Architecture, POWER6+, POWER6, POWER5+, POWER5, POWER, OpenPower, PowerPC, BatchPipes, BladeCenter, System Storage, GPFS, HACMP, RETAIN, DB2 Connect, RACF, Redbooks, OS/2, Parallel Sysplex, MVS/ESA, AIX, Intelligent Miner, WebSphere, Netfinity, Tivoli and Informix are trademarks or registered trademarks of IBM Corporation.

Linux is the registered trademark of Linus Torvalds in the U.S. and other countries.

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 Oracle Corporation.

JavaScript is a registered trademark of Oracle Corporation, used under license for technology invented and implemented by Netscape.

SAP, R/3, SAP NetWeaver, Duet, PartnerEdge, ByDesign, SAP Business ByDesign, 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 other countries.

Business Objects and the Business Objects logo, BusinessObjects, Crystal Reports, Crystal Decisions, Web Intelligence, Xcelsius, and other Business Objects products and services mentioned herein as well as their respective logos are trademarks or registered trademarks of Business Objects S.A. in the United States and in other countries. Business Objects is an SAP company.

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.