In the past mobilizing SAP has been a painful and expensive process. Most companies went with some form of middleware that is both very costly and complicated to implement. Others have tried to utilize the very difficult to use SAP Netweaver Mobile to put a mobile SAP application together, which typically results in a clumsy user interface.
Ladies and gentlemen, enter the age of open source paradise, where we no longer need to buy any additional software to build beautiful and robust mobile applications for SAP. In the next several posts I will be walking you through all of the necessary steps to make that happen.
What you will need
- SAP ECC 6.0 or higher – we need this version of SAP ERP software to be able to expose SAP functionality via web services
- A *nix-based local development environment. Any Apple machine works great, if you have the cash. Otherwise, you can build a Linux system for free on any good old laptop or desktop. I prefer the Ubuntu distribution. Here is a great guide on putting a local development environment with Ubuntu with Ruby on Rails (an awesome open source web development framework that we will be using in this article).
- Web server within your internal network so that it can “talk” to your SAP instance - a typical open source stack includes a Linux OS (can also use Ubuntu here), Nginx or Apache HTTP server, Passenger (to make the deployment a breeze), GIT version control system and Ruby on Rails. Guys over at Linode provide a nice set of guides on setting up Ruby on Rails web server on a variaty of different Linux distributions.
Exposing a Web Service in SAP
Let’s take care of the least fun part first – setup SAP to expose a web service that we will then use on our mobile application. The application we will build will allow you to unlock a user in SAP via your smart phone (iPhone or Android phone).
Create a Web Service
Log into your SAP development instance and proceed to transaction SE37 “Function Builder”. We are going to use an existing standard function module BAPI_USER_UNLOCK to mobilize the ability to unlock a user that has been locked due to numerous incorrect login attempts or any other reason. Input function module BAPI_USER_UNLOCK and click on the Display button.
Once you are in display mode of the function module, use the top menu Utilities > More Utilities > Create Web Service > From the Function Module. On the initial screen input Z_USER_UNLOCK in both Service Definition and Kurzbeschreibung fields (always a pleasure to have partially translated screens in SAP) and click Continue.
Simply click Continue at the Choose Endpoint step. We will define an endpoint separately later on.
On the next screen, titled Configure Service, choose PRF_DT_IF_SEC_LOW as the Profile and check the Deploy Service checkbox and hit Continue.
On the next screen, title Enter Package/Request, simply check the Local Object option and click Continue. This is done for the purposes of demonstration in this article. Once you decide to actually create something productive via the method described here, you will need to pick the appropriate development package and assign these changes to a transport request in SAP.
Click on the Complete button on the last screen.
Define Input and Output Parameters for Web Service
This is a little “gotcha” that can cause you a lot of headache. By default SAP will mark table parameters of function modules as both input and output, which causes tables that you expect to return output from the web service call to actually come back as blank. So, we need to go to transaction SE80 and update the web service Z_USER_UNLOCK that we just created.
Since we created the web service as a local object we can easily locate it in SE80 by choosing Local Objects in the drop-down on the left, input your SAP username and hit Enter. Now you should be able to find your Z_USER_UNLOCK web service under Enterprise Services > Service Definitions on the left tree. Double-click on the Z_USER_UNLOCK web service and click on the Display <-> Change icon in the top-left corner of the screen to enter Change mode.
Now go to the External View tab of the web service, open up Input parameters and double-click on Return table to open up the attributes of that input table. Since we expect to see results (success or failure) in the Return table and are not going to use this table as input parameter for our service call we need to uncheck the exposed attribute and then Save and Activate the service. As a general rule a table parameter within a function module should only be exposed as either an input or an output parameter within the web service definition.
Define an End Point
Note that you will need to perform this step in each system/client of SAP that you are planning to mobilize. In our example we are just going to do it in our development SAP system.
Proceed to transaction SOAMANAGER, click on the Business Administration tab and use the Web Service Administration link. Input Z_USER_UNLOCK into the Search pattern field and hit Go.
You should see your web service displayed in the table. Select your service by clicking on the square to the left of the service name and click on the Apply Selection button down below.
Select the Configuration tab down below and click on Create Service button, input Z_USER_UNLOCK in the New Service Name field, input Unlock user in the Description field, input Z_USER_UNLOCK into the New Binding Name field and click on Apply Settings.
Next, check the User ID/Password option under HTTP Authentication settings. Hit Save at the top of the screen.
Now select the Overview tab down below and click on Open WSDL document for selected binding link to get the URL for the WSDL that we will use in our next steps. For example, the WSDL URL might look something like this:
http://mycorporatedomain.com:1080/sap/bc/srt/wsdl/bndg_4CA1DAF7DEAB00C2E1008000AC18013D/wsdl11/allinone/ws_policy/document?sap-client=500
In the next post we will walk you through steps of consuming the SAP web service in Ruby on Rails which will then allow us to expose it to a smart phone of your choice.










Waiting for Part 2
me too =)
Very nice tutorial..
Waiting for Part 2
although some details like roles needed to create web service and expose it and type of authorizations and the way each needs to be handled at client side,will help a lot,cuz that’s what is the hiccup..
also configuring proxy for accessing the web service if you want to expose it outside your network..
Thanks
Very Good Tutorial.
I am waiting for part 2.