Inspired by some blogs about RESTFul Webservices (e.g. Android and RESTFul web service instead of SOAP (Android and RESTFul web service instead of SOAP) ) I will show you a short example how easy it is to consume SAP data in a mobile app built with rhomobile.
There are several different frameworks for web apps (http://wiki.sdn.sap.com/wiki/pages/viewpage.action?pageId=197034098) available. Here I will show you an example built with Rhomobile which makes use of the Rhodes framework. It is an open source Ruby-based framework to build native apps for iPhone, Android, RIM and Windows Phone. In order to get started you only need to install Rhostudio (http://rhomobile.com/) which includes the Rhodes framework, the RhoStudio Eclipse IDE and RhoConnect, a server that connects your mobile devices with your backend systems like SAP.
Building my example app was done by the following steps:
Creating a Rhoconnect application
Creating a Rhoconnect Source Adapter
Creating a Rhodes Application
Creating a Rhodes Model
For step 1 I created a simple web service that reads table SCARR and serves the result as a JSON object created using the ABAP JSON Document Class (https://cw.sdn.sap.com/cw/groups/zjson) from SAP CodeExchange. The result looks like this:
The remaining steps are done in the RhoStudio Eclipse IDE. For steps 2 to 5 you only need to follow the 'Create ...'-Wizards in Eclipse.
Consuming the SAP data needs only inserting some lines of Ruby code into the generated SourceAdapter class that you can see below:
This is all that is needed for our RhoConnect application for synchronizing the data between SAP and the RhoConnect server (please keep in mind that I only implemented the READ functionality in this example). The model of our 'Airline' data object is createdby simply naming the fields of table SCARR:
After these steps you only need to enable sync of data between the application and the RhoConnect server (by uncommenting 'enable: sync' in the model class) and implement the model into the view by adding "<%= url_for :controller => :Airline %>" into the generated code.
Running the example Application
After starting the simulator and logging in you get the following overview:
Selecting an entry directs you to the detail view of the entry. In the standard generated code the CRUD (Create-Read-Update-Delete) functionality is already implemented. Therefore in the example code you can edit the data but synchronizing it to SAP does not alter the data unless I implement it in SAP.