Skip to Content
Author's profile photo Ferry Gunawan

Auto Device Registration in SAP Mobile Platform with Sencha Touch

Hi to all,

What I would like to share in this blog is how we are going to create an app using Sencha Touch 2 that is able to perform device registration automatically in the SAP Mobile Platform.

What You Need

These are the components that you need in order to execute the app:

Setting Up Application ID in SAP Mobile Platform

  • After you have registered an account in, please log-on and it will bring you to the SAP HANA Cloud Platform Cockpit
  • Go to  Account Information > Services > SAP Mobile Platform
  • You will see the main Home page. Please go to Applications page and click New
  • Under New Application, fill in the following information. For the application ID com.FD.Demo, please take a note carefully of this name convention. We will use this naming convention in our Sencha code.








FD Demo


  • Under Back End, fill in the following information:


Connect to


Rewrite URL


Allow anonymous connection



Username (for example: P1940517116)




You can use any OData services available from SAP OData backend service that you have registered. I am using the CountryCollection to get the country description:

  • Continue with Authentication. Go to this tab, select New for the Security Profile and fill in the below information then click Save.

Security Profile Name


Authentication Type

Basic Authentication

Authentication URL

Connect to



Test the SAP Mobile Platform Connection

To test the setting that we have done it in the above steps, please go to the Application page, select the application ID that we have created, com.FD.Demo and click Ping. If successful, you will see the green checked icon status for both Backend and Security profiles.


Setting up Sencha Touch

Don’t worry about writing the codes, you can download the source code from the Github site:

You can create a new app in Sencha working folder by typing:

sencha -sdk “<path_to_ SDK touch-2.3.1>” generate app -name <Name_of_App> -path “<path_to_App>”

For example, if you want to create the Sencha app named with FD4 and SDK folder is in C:\touch-2.3.1 and your Sencha working folder is in C:\SenchaTouch\FD4, then you can type the following command in the command-prompt:

sencha -sdk “C:\touch-2.3.1” generate app -name FD4 -path “C:\SenchaTouch\FD4”

In this app, a user will enter the country code to get the description of the country code. The country code entered by the user will be passed to OData service:‘<country_code>’)

If the country code exist, it will print the country code description in another page.


In order to access the data from SMP, firstly we need to register the device in the SMP. Below simple workflow describes the logic to connect to the application ID. This process will be executed every time the app is loaded. Please put this under controller init function: /app/controller/note.js > init.function().


  • First step is to check if it can connect to application ID. It performs a simple Ajax GET request to

    url: '<apache_web_server>/sapgw/com.FD.demo'
    headers: {
    "Content-Type" : "application/atom+xml; charset=UTF-8",
    "Authorization" : 'Basic UDE5NDA1MTcxMTY6UGFwYW1hbWExOA=='
    method: 'GET',
    withCredentials: true,
    useDefaultXhrHeader: false,
    disableCaching: false

The Authorization value above is the result of the base64.encode of your username and password in the SAP OData backend service. The above code is calling the application ID com.FD.Demo that we have defined in the SMP and perform the GET request.


application/atom+xml; charset=UTF-8



XML Body

<?xml version=”1.0″ encoding=”utf-8″?>
<entry xmlns=”” xmlns:m=”” xmlns:d=”“>
<content type=”application/xml”>

where devtype is one of these combinations depending on the OS’ client:
iPad, iPhone, iPod, iOS, Android, Blackberry, Windows, Unknown

    if(response.statusText == 'Not Found' || response.statusText == 'Forbidden' ) {
    if( {
    devtype = 'iPad'
    } else if( {
    devtype = 'iPhone'
    } else if( {
    devtype = 'iPod'
    } else if( {
    devtype = 'iOS'
    } else if( {
    devtype = 'iOS'
    } else if( {
    devtype = 'Android'
    } else if( {
    devtype = 'BlackBerry'
    } else if( {
    devtype = 'Windows'
    } else if( {
    devtype = 'Unknown'
    var regXML = '<?xml version="1.0" encoding="utf-8"?>' +
    '<entry xmlns="://" xmlns:m="://" xmlns:d="://">' +
    '<content type="application/xml">' +
    '<m:properties>' +
    '<d:DeviceType>' + devtype + '</d:DeviceType>' +
    '</m:properties>' +
    '</content>' +
    url: '//<apache_web_server>/sapgw/odata/applications/latest/com.FD.Demo/Connections',
    headers: {
    "Content-Type" : "application/atom+xml; charset=UTF-8",
    "Authorization" : 'Basic UDE5NDA1MTcxMTY6UGFwYW1hbWExOA=='
    method: 'POST',
    withCredentials: true,
    useDefaultXhrHeader: false,
    xmlData: regXML,
    disableCaching: false
  • If the registration process is successful, you will see the application connection ID with the status registered under Application Connection tab. You can see the device type is Windows because I am running the app in my Windows OS. If you are running the app from your iPhone, you will see the device type is iPhone. Please try it.
  • During registration process, user will not be able to interact with the app. Once it is completed, user can continue.

Hopefully the above blog will benefit you to gain insight and experience in using the SAP Mobile Platform. Off course you also can put the log-on page before the app checks the connection ID to enforce the security.

Thanks for reading my blog and feel free to drop me any comments.

Assigned Tags

      Be the first to leave a comment
      You must be Logged on to comment or reply to a post.