Quantcast
Channel: SCN : All Content - SAP Gateway
Viewing all articles
Browse latest Browse all 2823

How to create Android Application consuming OData Service with help of Gateway Productivity Accelerator (GWPA)

$
0
0

It was my dream to build at least one android application which will display SAP data on mobile/tablet devices. As I am not very much skilled in developing android application, I was struggling on how to start with this. And then I came across GWPA and started exploring it. I explored it; I liked it and now I'm loving it!

It is very simple to create android application consuming OData with the help of Gateway Productivity Accelerator (GWPA) plug in installed on Eclipse IDE.

Let’s get into the details,


Introduction -


In this technical blog, I will focus on how we can build simple Android application consuming OData service with the help of SAP NetWeaver Gateway Productivity Accelerator (GWPA).


To know more about GWPA, please refer http://scn.sap.com/community/netweaver-gateway/blog/2013/06/03/gateway-productivity-accelerator-10-launched


It can be downloaded from https://tools.hana.ondemand.com/#gateway

 

Prerequisites –


We need to follow steps as mentioned below [Reference - https://tools.hana.ondemand.com/#gateway ]

Installation Instructions

To start using SAP NetWeaver Gateway Productivity Accelerator (GWPA), proceed as follows:

  1. Download and install Java SE6 .
  2. Download and install the Eclipse IDE for Java EE Developers from Eclipse .
  3. Install the SAP NetWeaver Gateway Productivity Accelerator (GWPA) feature(s).

From the Eclipse menu, choose Help> Install New Software...
Add the URL
https://tools.hana.ondemand.com/juno.
Select the feature(s) you want to install and follow the steps of the installation wizard.
For information about the individual features, see the documentation.

 

To Develop Android application using GWPA, we need to install Android SDK tools on Eclipse IDE and then install GWPA features.

  • Toolkit for Android (GWPA)
    The Android Toolkit consists of an environment, a pattern and templates, suitable for developing SAP solutions for use in the Android environment.
    Prerequisite for installation of this feature is to install the
    Android SDK Tools.


Once you install Android SDK tools, it will look as below under Window --> preferences.

android_gw1.jpg

After doing all these steps, I faced issue with android application regarding getting error, “R cannot be resolved to a variable” and hence after searching lot on it, I resolved it by installing Android SDK Build-tools and hence your Android SDK Manager image should look as below.

android_gw2.jpg

After this step, you can start installing Toolkit for Android (GWPA) as mentioned below. You need to select checkbox for Toolkit for Android (GWPA).

android_gw3.jpg

Once installed successfully, you can open Windows --> Preferences and check under SAP NetWeaver Gateway.

android_gw4.jpg

Please note: we do not require separate installation for SAP OData Mobile Client SDK.

With all above required steps, you are now ready to develop Android application!

 

Procedure -

Create new project. Under OData Development, select Starter Application Project.

android_gw5.jpg

Give appropriate project name, select Build Target and package name and press Next.

android_gw6.jpg

We can create 3 types of application using below templates. Here, we will select List/Details Application.

android_gw7.jpg

Now, we need to select service URL from Remote location. Click on Catalog.

android_gw8.jpg

Click on Manage Connection if no connection is maintained earlier.

android_gw9.jpg

As displayed below, provide required details and click OK.

android_gw10.jpg

P.S. - If you do not have access to SAP NetWeaver Gateway system then you can access demo system from SAP at http://scn.sap.com/docs/DOC-31221?rid=/webcontent/uuid/1051f6d9-e87a-2e10-d188-e2786c7878b1 and accordingly configure connections and access OData services. Please refer my blog http://scn.sap.com/community/developer-center/front-end/blog/2013/05/31/how-to-create-sapui5-application-consuming-gateway-service-with-the-help-of-sap-nw-gateway-plugin and see section Additional Details for more information.


If the connection is made, you will be able to see services. For this demo, we will select service RMTSAMPLEFLIGHT and click OK.

android_gw11.jpg

Provide Activity title, select Activity type and add fields.

android_gw12.jpg

Add 2nd Activity of type Details.

android_gw13.jpg

We selected Flights as List activity and FlightBooking as Details Activity. Our final project structure will look something like below screen.

android_gw14.jpg

As displayed below, SAP Gateway system service details will be found under res/raw folder.

android_gw15.jpg

Also the auto-generated code provides commented code to handle Sybase Unwired Platform (SUP) server mode. This is really nice feature as when we have SUP, we need not to modify much logic.

android_gw16.jpg

Now we are ready with Android application and want to test it. To test android application, you can use Real device or Android Emulator http://developer.android.com/tools/help/emulator.html


We need to manage device using AVD. Please refer http://developer.android.com/tools/devices/index.html


An Android Virtual Device (AVD) is an emulator configuration that lets you model an actual device by defining hardware and software options to be emulated by the Android Emulator.


As displayed below, AVD can be added.

android_gw17.jpg

That’s it!!!


Now we are absolutely ready to test our application on emulator. We need to test as mentioned below,

android_gw18.jpg

Under Console screen, you will be able to see the log of AVD launch etc...

android_gw19.jpg

Please note: Android emulator sometime is very slow and hence you need to be patience and can take break for Coffee.


 

AVD will launch emulator device as displayed below,

android_gw20.jpg

Here sometime you need to press F2 or keyboard commands as per your AVD settings. Refer Keyboard commands at http://developer.android.com/tools/help/emulator.html


You may see screen as below. Here you can see all your Android based application. In this case, you can see MyFlightAndroidApp. Double click on app icon.

android_gw21.jpg

It will launch login screen. Provide credentials that you used while connecting to your gateway SAP system.

android_gw22.jpg

Under LogCat window, you will see the log of application being executed.

android_gw23.jpg

After successful launching, you will see the Flights list view.

android_gw24.jpg

Selecting any item will open details screen for FlightBooking as below

android_gw25.jpg

You can search for different flight id and it will be displayed accordingly.

android_gw26.jpg

Note that under LogCat window, all these events will be logged which can be very useful for troubleshooting purpose.

android_gw27.jpg

 

Closing Remarks –


With the help of SAP NetWeaver Gateway Productivity Accelerator (GWPA), we can create Android application with very minimum efforts.

This step-by-step blog is written to explain how we can,


  1. Install Android SDK tools, GWPA etc. in Eclipse IDE.
  2. Configure SAP NetWeaver Gateway system and search for OData services
  3. Create simple Android application
  4. Configure and Launch Android application on ADV
  5. Use Console and LogCat for troubleshoot purpose

 

 

GWPA is extremely helpful tool from SAP to leverage OData capability and it will certainly helpful for all developer community who want to develop simple android application based on SAP business suite data in the form of OData.


It is generating starter application which we can modify as per our business/organizational requirement


Viewing all articles
Browse latest Browse all 2823

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>