I strongly recommend you to use the new version of the toolkit for Android in Gateway Productivity Accelerator (more info in this blog: http://scn.sap.com/community/netweaver-gateway/blog/2013/05/10/new-gateway-tool--sap-netweaver-gateway-productivity-accelerator).
The blog is still relevant, except that SAP NetWeaver Gateway plugin for Eclipse 2.5.2 is superseded by Gateway Productivity Accelerator 1.0.
It has never been easier to create mobile based applications connected to SAP systems. The SAP NetWeaver Gateway offers access to processes and data from a standard SAP Business Suite system (ERP, CRM ...) via open protocols.
Together with the SAP NetWeaver Gateway plugin for Eclipse, anyone with a passion for Android development can immediately start using Gateway!
Starting with version 2.5.2 of the plugin, an Android Toolkit is available, enabling the native Android developer to easily develop applications that consume SAP NetWeaver Gateway services.
Today I will show you how easy it is to create an Android application that reads and displays data from SAP NetWeaver Gateway.
I assume you already have a running Eclipse IDE with the Android Developer Tools (ADT) plugin for Eclipse installed.
First thing you’ll need to do is to download and install the SAP NetWeaver Gateway plugin for Eclipse. Once installed, the second step will be to configure an NW Gateway system connection. I’ll be using the online NW Gateway demo system. To configure it, go to Eclipse Preferences and add a new connection under SAP NetWeaver Gateway > Connections.
One last thing before we can start, since the Android Toolkit is based on the SAP OData Mobile SDK, we need to download the SDK, and extract to a location on the file system. Then all we have to do is to set the path to where we have extracted the libraries, in Eclipse Preferences under SAP NetWeaver Gateway > Android Toolkit.
Now that we are done with the formalities, we can go ahead and use the plugin to create an Android app. Start by opening the New Project wizard and select Starter Application Project under the SAP NetWeaver Gateway node. Give your project a name, and select Android from the dropdown of available target platforms. Follow the wizard steps and select the List/Details Application template from the templates page of the wizard.
The service I will use in my application is the sample service that exposes data from the good old Flight sample application, and is available in SAP NetWeaver since many years. This is also the first example found under Sample Gateway Services in the NW Gateway demo system page on the SCN.
We have several ways to select the service to base our application on, but let’s try out the nice Catalog functionality to explore the Gateway service catalog. Clicking the Catalog button will open the service catalog. In case you skipped the connection configuration step, no worries, you can still do it without closing the wizard (simply click on the Configure… link and add the online demo system details).
Search for: *flight to display all services on this system that deal with flight data. The service I’m looking for is RMTSAMPLEFLIGHT_2.
We are almost done!
The final step of the List Template is to model the application pages (activities).
The modeling is quite intuitive: we start with a List activity that displays data from a selected collection of the service (Entity Set Navigation) in a list manner. Pick a few fields to appear on each entry in the list.
For example, I want to have a list of flight carriers as my first page. Then, on clicking a specific carrier I would like to list the carrier’s flights. So I add another page, and select its type to a List, and its Entity Set Navigation to CarrierFlights. I pick a couple of fields that describe a flight entry (for example, the flight number and date).
Last but not least I add a third page, this time of type Details to display detailed information on a specific flight, and add all fields.
Then, I click the Finish button of the wizard. A new Android project is generated containing a semantic proxy for the service I selected and application logic and resources according to my modeling. Also, the SAP OData Mobile SDK libraries are copied into the project under libs folder.
Now I can already run the application in an emulator or on a real Android device and check it out.
In runtime, you need to enter a username and a password for login. Just enter the same credentials you used to configure the Demo System.
Note that if working behind a proxy you might need to configure the proxy host and port in the application to avoid an Unknown Host Exception. For instructions on how to do that, refer to the troubleshooting guide – page 105 in the SAP NetWeaver Gateway plug-in for Eclipse guide.
I hope you find this blog helpful. Keep in mind that this is just a starting point for understanding how to consume Gateway services in an Android application. You can customize the generated project code manually like adding or removing pages, changing the layout and icons or add additional functionality.
Feel free to share in the comments section any customization and/or feedback you have.
To be updated on future #SAPGateway blogs and updates please follow us @shirilevil