SAP Mobile01

Embed Size (px)

Citation preview

  • 8/3/2019 SAP Mobile01

    1/31

    SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com

    2010 SAP AG 1

    SAP goes mobile! Part 1

    Applies to:SAP ERP 6.0

    Netweaver > 7.10

    Summary

    This tutorial is starting point for a series of tutorials demonstrating different ways of how to create mobileclients on top of SAP systems. We will chalk out ways of creating so called "instant value applications"without even touching the iPhone or Android development environment - all you need is basic understandingof SAP and Java.

    Author(s): Pascal Kaufmann, Pascal Moser, Florian Mller

    Company: Resource AG, http://www.resource.ch

    Created on: 15 November 2010

    Author Bio

    Pascal Kaufmann is working as NetWeaver technology consultant for Resource AGSwitzerland (http://www.resource.ch), a Swisscom company. Pascal counts ABAPdevelopment for web technologies and process integration with SAP PI to his main skills.For further information hes reachable via

    [email protected]

    Pascal Moser works as a SAP Development Consultant for Resource AG for more thanfive years. He develops applications and components for the SAP Portal in Web Dynpro(mainly Java) and ABAP applications for several R/3 Systems (Finance, HR, CRM, ).

    [email protected]

    Florian Mller works as a Solution Architect for Resource AG, one of the leading SAPconsulting companies within Switzerland. Florian focuses on SAP UI technologies in firstplace, especially mobile UI technologies are part of his daily SAP business. FurthermoreFlorian is founder of richability (http://www.richability.com) and frequent author for severalmagazines and books within the space of Java & UI Technologies.

    [email protected]

  • 8/3/2019 SAP Mobile01

    2/31

    SAP goes mobile! Part 1

    SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com

    2010 SAP AG 2

    Table of Contents

    Preface .......................................................................................................................................................... 3

    1 Tutorial Structure ..................................................................................................................................... 3

    2 Requirements .......................................................................................................................................... 4

    3 The big picture ......................................................................................................................................... 43.1The Scenario ............. .............. .............. .............. ............... .............. .............. .............. .............. .............. .............. . 4

    3.2The architecture behind ............. .............. .............. .............. .............. .............. .............. .............. .............. ............. 64 Web Service creation within ERP ............................................................................................................ 7

    4.1Web Service creation .............................................................................................................................................. 7

    4.2Deploy Web Service ............. .............. .............. .............. .............. .............. .............. .............. .............. ............... . 21

    4.2.1 Additional adaptions ............. .............. ............... .............. .............. .............. .............. .............. .............. ...... 26

    4.3 Test the Web Service ............................................................................................................................................ 28

    5 Next steps .............................................................................................................................................. 31

  • 8/3/2019 SAP Mobile01

    3/31

    SAP goes mobile! Part 1

    SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com

    2010 SAP AG 3

    SAP goes mobile!

    Preface

    As you might have noticed there is happening a lot within the space of mobile application development.Focusing on SAP applications and tooling there is Sybase on the one hand, on the other hand there is SAPNetweaver mobile platform, both frameworks apply to what we gently call heavy frameworks be assuredyou need several consultants and SAP trainings in order to establish this landscape within your company or

    your customers environment...

    But there is another approach as well it is not hyped the way Sybase is currently celebrated but for certainrequirements applies much better than heading for a heavy approach. Of course you can use a sledge-hammer to crack a nut but there might be alternatives around.

    During this series of tutorials we will come up with several ways of implementing mobile frontends for yourSAP system. As we know that it is not on everybodys agenda to buy a Macbook before we actually startcreating iPhone/iPad user interfaces we will show ways of using powerful HTML5 frameworks which result in100% iPhone/iPad look and feel, have a look at the following screen, this is what based on HTML5 can beachieved:

    Caption1:HTML5basedFlightBAPIapplicationrunningwithiniPhoneclient

    But dont be afraid you do not need any HTML5 knowledge, all we will do is coding plain Java and triggerseveral Web Services. Btw., the same applies to Android applications we will show you ways of creatingAndroid clients within minutes instead of becoming Android expert before you actually start your firstapplication. And of course, in oft the last parts of our tutorial we will show you how to create nativeiPhone/Android apps.

    You simply should keep in mind: this tutorial gives chance to anybody to create so called instant valuemobile apps which path you follow is completely up to you and your requirements!

    1 Tutorial Structure

    The following parts will be covered within this series of tutorials. Please consider the given dates as targetedrelease dates, we hope to achieve these targets but as already said these dates are targeted, not fixed;

    1. Boilerplate:coverscreationofbackendwebserviceswithinyourERP(coveredwithinthisdocument)

    15/11/2010,Contact/Feedback:[email protected]

  • 8/3/2019 SAP Mobile01

    4/31

    SAP goes mobile! Part 1

    SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com

    2010 SAP AG 4

    2. EclipseConnect:EclipseIDEwillbeusedasmajordevelopmentIDE.Beforewe

    actuallyhookthewebserviceintoarealmobileclientwewillcreateallnecessary

    JavastubsinordertoaccesstheSAPWebServices

    25/11/2010,Contact/Feedback:[email protected]

    3. SAPiPhonehandshake:wewillusethevaadinframeworkwithintheEclipseIDEandcreatethemobileclientwhichconsumesthepreviouslycreatedWebServices

    01/12/2010,Contact/Feedback:[email protected]

    4. SAPAndroidhandshake:creationofmobileAndroidclient(basedonAdobeAIR)accessingSAPWebServicespreviouslycreated

    releasedatefollows...

    5. SAPnativeiPhone:wewillcreateanativeiPhoneclient(Mac+XCodeIDErequired)accessingourSAPWebServicereleasedatefollows...

    2 Requirements

    Each tutorial requires certain skills, software and hardware so we will create a brief list of requirementswithin the head of each tutorial. Please dont be afraid in terms of I will fail as I have no clue on iPhone

    development..., you do not need to know anything about mobile application development as we will showyou during these tutorials!

    Anyway, there are major requirements which should be met, you need to be familar (basic knowledge) with:

    ABAPbasics(knowhowtofireupse80...)

    BasicunderstandingofWebServices(SOAP)

    BasicJavaknowledge

    In order to follow this tutorial you will require:

    SAPERP6.0

    Netweaver>=7.10

    Any additional software you will require is explained within the tutorial such as Eclipse, SOAP UI etc..

    3 The big picture

    Before we start the creation of SAP Web Service boiler plate we will give you some information on what wewill be implementing and we will chalk out the very big picture of what we would call the architecture behindthe application.

    3.1 The Scenario

    People told me (as Im from the Java world and did not go through all these SAP classes) that FLIGHTBAPI is something similar to what Java guys call Hello World in terms of everybody knows these BAPISand everybody has these BAPIS around on his ERP system somewhere. So we will use these BAPIS andput a Web Service interface above these so you can access these BAPIS through the Web Service.

    From the SAP point of view we are done as soon as these BAPIS can be access through a Web Service, ofcourse you can turn/cover any BAPI into a Web Service and that is exactly the idea of showing you how todo so: you will be able to publish any BAPI you want as a Web Service and of course you will be able to puta nice mobile UI on top of your Web Service so you FLIGHT BAPI as starting point, as soon as you got theidea start applying your knowledge to customer projects...

    We will do some simple calls based on these Web Services, we will trigger a flight search passing indeparture as well as destination and our mobile device will display the query results:

  • 8/3/2019 SAP Mobile01

    5/31

    SAP goes mobile! Part 1

    SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com

    2010 SAP AG 5

    Caption2:Enterdeparture&destinatio,alistofflightswillbereturned...

    Caption3:FlightresultsprovidedbyFlightBAPIviaWebService...

  • 8/3/2019 SAP Mobile01

    6/31

    SAP goes mobile! Part 1

    SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com

    2010 SAP AG 6

    Caption4:FlightdetailsprovidedbyBAPIviaWebServicegateway...

    3.2 The architecture behind

    As already said we do not want to bother you with XCode development during the first parts of this tutorial all UIs will be created based on alternative technologies such as HTML5. Please have a look into thefollowing scribble, this sccribble chalks out the very big picture of what we will be implementing.

  • 8/3/2019 SAP Mobile01

    7/31

    SAP goes mobile! Part 1

    SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com

    2010 SAP AG 7

    Caption5:Architecture

    Within the current tutorial we will create everything which is grouped in the grey box at the bottom of thisscribble. The blue box applies to what SAP calls Reverse Proxy, please do not focus on security aspectswhen working through the first parts of this tutorial series now we will cover security aspects in a dedicatedtutorial! We simply refer to the blue box as Java client layer, the blue box is used in first place forgeneration of HTML5 through frameworks such as vaadin & co...

    No that you got the big picture its time to get the grey box working so lets roll up ones sleeves and createsome Web Services within our ERP!

    4 Web Service creation within ERP

    On the one hand we will create a Web Service interface for the FLIGHT BAPI on the other hand we willdeploy the Web Service in order to access the Web Service; last but not least we will test the Web Serviceusing SOAP UI a free Web Service testing tool.

    4.1 Web Service creation

    As we assume basic SAP knowledge we simply provide screenshots and briefly explain what we will bedoing as the focus of these tutorials should be put rather to mobile application development instead of SAP

  • 8/3/2019 SAP Mobile01

    8/31

    SAP goes mobile! Part 1

    SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com

    2010 SAP AG 8

    basics if you have any questions, feel free to contact us, questions related to Web Service creation can besend to Pascal Moser directly as he ist he technical guy behind this part of the tutorial([email protected])

    1) Fire up SE80 ABAP workbench

    2) Create development package

  • 8/3/2019 SAP Mobile01

    9/31

    SAP goes mobile! Part 1

    SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com

    2010 SAP AG 9

    3) create function group within the created package:

  • 8/3/2019 SAP Mobile01

    10/31

    SAP goes mobile! Part 1

    SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com

    2010 SAP AG 10

    4) create function module

  • 8/3/2019 SAP Mobile01

    11/31

    SAP goes mobile! Part 1

    SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com

    2010 SAP AG 11

    (if you require several function modules, simply repeat step 4))

    There are two ways of filling a table with information and send this information back to the calling application:you can define the parameter as export or table parameters. We recommend to define an export parameter:

  • 8/3/2019 SAP Mobile01

    12/31

    SAP goes mobile! Part 1

    SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com

    2010 SAP AG 12

    Option Export parameter:

    If you define the table as an export parameter, the Web Service will send back the table automatically withinthe returning SOAP XML. The call looks like this:

    Option Table Parameter:

    If you decide to use the table parameter variant you explicitly have to tell the Web Service that to return thistable. The call looks like this (see red mark):

    JL

    FRANKFURT

    TOKYO

    2010-06-05

    15:00:00

    22:00:00

    JL

    FRANKFURT

    TOKYO

    2010-06-05

    15:00:00

    22:00:00

  • 8/3/2019 SAP Mobile01

    13/31

    SAP goes mobile! Part 1

    SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com

    2010 SAP AG 13

    5) Transfer function group to Web Service - this will create the required Web Services hooking into theBAPIs.

  • 8/3/2019 SAP Mobile01

    14/31

    SAP goes mobile! Part 1

    SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com

    2010 SAP AG 14

  • 8/3/2019 SAP Mobile01

    15/31

    SAP goes mobile! Part 1

    SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com

    2010 SAP AG 15

  • 8/3/2019 SAP Mobile01

    16/31

    SAP goes mobile! Part 1

    SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com

    2010 SAP AG 16

  • 8/3/2019 SAP Mobile01

    17/31

    SAP goes mobile! Part 1

    SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com

    2010 SAP AG 17

  • 8/3/2019 SAP Mobile01

    18/31

    SAP goes mobile! Part 1

    SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com

    2010 SAP AG 18

    (at position 1, enter your package name)

  • 8/3/2019 SAP Mobile01

    19/31

    SAP goes mobile! Part 1

    SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com

    2010 SAP AG 19

    6) generate Web Service

  • 8/3/2019 SAP Mobile01

    20/31

    SAP goes mobile! Part 1

    SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com

    2010 SAP AG 20

    7) Open SOA Manager

  • 8/3/2019 SAP Mobile01

    21/31

    SAP goes mobile! Part 1

    SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com

    2010 SAP AG 21

    4.2 Deploy Web Service

    8) Select your entry (ZS_WS_FLIGHT) and click "Apply Selection"

    9) Switch to TabStrip Konfiguration and create a new service

  • 8/3/2019 SAP Mobile01

    22/31

    SAP goes mobile! Part 1

    SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com

    2010 SAP AG 22

    (use same name for Servicename and binding)

    10) Switch to the tabStrip Overview and define the authentication data

  • 8/3/2019 SAP Mobile01

    23/31

    SAP goes mobile! Part 1

    SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com

    2010 SAP AG 23

  • 8/3/2019 SAP Mobile01

    24/31

    SAP goes mobile! Part 1

    SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com

    2010 SAP AG 24

    (Save the service)

    11) Define system base configuration

  • 8/3/2019 SAP Mobile01

    25/31

    SAP goes mobile! Part 1

    SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com

    2010 SAP AG 25

    12) Go back to Web Service

    13) Open the WSDL

  • 8/3/2019 SAP Mobile01

    26/31

    SAP goes mobile! Part 1

    SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com

    2010 SAP AG 26

    14) Open and save the WSDL in order to use it for the Web Service call

    4.2.1 Additional adaptions

    Basically your Web Service is ready to run at this point of the tutorial. As already mentioned this tutorialfocuses majorly on the User Interface creation, so we recommend in case you could not follow to this point toget yourself familar with the creation of Web Services on top of the ABAP stack, this link will give you somemore detailed explanations on how to connect your BAPIs to Web Service interfaces:

    http://help.sap.com/erp2005_ehp_04/helpdata/DE/9b/dad1ae3908ee44a5caf57e10918be9/frameset.htm

    We also like to point out we did some slight modifications to our function module as the "default BAPI" fromthe flight list does not apply to the input parameters we would like to use, see the following screenshot, that'swhat the default web service based on BAPI_SFLIGHT_GETLIST requires:

    Our function module applies to the following parameters, the listing for the module adaptions can be foundbelow:

    FUNCTION Z_FLIGHT_GETLIST.*"---------------------------------------------------------------------- *"*"Lokale Schnittstelle:*" IMPORTING

  • 8/3/2019 SAP Mobile01

    27/31

    SAP goes mobile! Part 1

    SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com

    2010 SAP AG 27

    *" VALUE(IMW_AIRLINEID) TYPE S_CARR_ID OPTIONAL*" VALUE(IMW_CITY_FROM) TYPE S_CITY OPTIONAL*" VALUE(IMW_CITY_TO) TYPE S_CITY OPTIONAL*" VALUE(IMW_DEPARTURE_DATE) TYPE S_DATE OPTIONAL*" VALUE(IMW_DEPARTURE_TIME_FROM) TYPE S_DEP_TIME DEFAULT*" '00:00:00'*" VALUE(IMW_DEPARTURE_TIME_TO) TYPE S_DEP_TIME DEFAULT '24:00:00'*" EXPORTING*" VALUE(EXT_FLIGHTS) TYPE Z_ALADIN_FLIGHT_LIST_TTYPE

    *"----------------------------------------------------------------------

    DATA: LR_DEST_FROM TYPE BAPISFLDST,LR_DEST_TO TYPE BAPISFLDST,lt_flight_list type Z_ALADIN_FLIGHT_LIST_TTYPE,lr_flight_list LIKE LINE OF lt_flight_list.

    LR_DEST_FROM-CITY = imw_city_from.lr_dest_to-city = imw_city_to.

    CALL FUNCTION 'BAPI_FLIGHT_GETLIST'EXPORTING

    AIRLINE = imw_airlineidDESTINATION_FROM = LR_DEST_FROMDESTINATION_TO = lr_dest_to

    * MAX_ROWS =TABLES

    * DATE_RANGE =* EXTENSION_IN =

    FLIGHT_LIST = lt_flight_list.* EXTENSION_OUT =* RETURN =

    IF not imw_departure_Date is INITIAL.LOOP AT lt_flight_list into lr_flight_list.

    IF lr_flight_list-FLIGHTDATE = imw_departure_Date andlr_flight_list-DEPTIME = imw_departure_time_from.

    APPEND lr_flight_list to ext_flights.

    ENDIF.ENDLOOP.

    else.LOOP AT lt_flight_list into lr_flight_list.

    IF lr_flight_list-DEPTIME = imw_departure_time_from.

    APPEND lr_flight_list to ext_flights.

    ENDIF.ENDLOOP.

  • 8/3/2019 SAP Mobile01

    28/31

    SAP goes mobile! Part 1

    SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com

    2010 SAP AG 28

    * APPEND LINES OF lt_flight_list TO ext_flights.ENDIF.

    ENDFUNCTION.

    Usage of this function module enables you to pass in the following parameters to the Web Service:

    AirlineIDCity of DepartureCity of destination

    Departure DateDeparture TimeArrival Time

    As a result a list of flights will be returned, that's actually the final Web Service all further mobile userinterfaces will be put on top. So please make sure your Web Service applies to these parameters;

    4.3 Test the Web Service

    As the Web Service is deployed to your Netweaver application server now it's time to test the Web Service.Before we actually start shooting the Service from a Java stack we will use a nice little tool in order to test,the tool is called soapUI, you can download the tool for free using the following link:

    http://www.soapui.org/

    So what does this tool do? Basically you can simply pass in a WSDL destination and SOAP UI will create thecorresponding SOAP request. You can pass in some parameters and will receive the result of the call in anice textual manner.

    Follow these steps to ensure your Web Service is working correctly, this is a great chance to become"familar" with your service, you will nee a basic understanding of parameters being passed in parametersbeing returned.

    1) Install soapUI

    2) Launch soapUI, create a new project and pass in the WSDL URL during project cretion (see parameterInitialWSDL/WADL):

    3) soapUI will parse the WSDL and create a corresponding request, expand your project to the request itemand double click on the request item, the request details will be displayed

  • 8/3/2019 SAP Mobile01

    29/31

    SAP goes mobile! Part 1

    SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com

    2010 SAP AG 29

    ?

    ?

    ?

    ?

    ?

    ?

    4) Next you simply can modify the Web Service request, as we have specified all parameters as optionalparameters, you should be able to receive flight results without passing in parameters; or you simply addparameters but make sure to remove all of the included "?" before you start firing the Web Service. We leftone parameter in order to return all flights from the "LH" carrier which will return all Lufthansa flights...:

    LH

    Execute the request, it should return a list of flights:

  • 8/3/2019 SAP Mobile01

    30/31

    SAP goes mobile! Part 1

    SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com

    2010 SAP AG 30

    LH

    Lufthansa

    0400

    2010-05-08

    FRA

    FRANKFURT

    JFK

    NEW YORK

    10:10:00

    11:34:00

    2010-05-08

    666.0

    EUR

    EUR

    LH

    Lufthansa

    0400

    2010-06-05

    FRA

    FRANKFURT

    JFK

    NEW YORK

    10:10:00

    11:34:00

    2010-06-05

    666.0

    EUR

    EUR

    ....

    Done! Your Web Service is accessable now and we can simply start using the Web Service and put somenice mobile UIs on top of your Web Service. Be assured, the next parts of the tutorial series will be explained

  • 8/3/2019 SAP Mobile01

    31/31

    SAP goes mobile! Part 1

    more detailed as we will do something completely new to you, but as we have to assume some SAP basicunderstanding we have to assume some basic understanding of SAP.

    5 Next steps

    The next tutorial ( will be released next week) will show you how to link your Web Service to Java andApache Axis2. Of course your Web Service returns an XML String and you could parse the String on yourown, but this would take a lot of time - so Axis2 will become your best friend as Axis2 generates Java

    Objects based on your WSDL. In a nutshell, the next tutorial part will simply chalk out how to automaticallytransform Web Service results to plain Java objects.