ABAP Report => Mobile Application automated by zMob!
zMob is a powerful platform allowing the generation of mobile applications from simple ABAP reports. Behind the scenes, the report is converted into a mobile UI and passed to the end user’s mobile device. Once data is collected, the user submits the data back to the SAP system, where your report processes the result in real-time. Your report writes lines that are relayed back to the mobile device, processed for special tags and rendered for the user.
The zMob library for SAP is open source (dual licensed under the LGPL and a commercial license,) and can be downloaded from the project page at https://bitbucket.org/zmob/sap.
A project using zMob to generate a mobile application from ABAP reports is Microbe, an open source (MIT) microblogging platform. A recent article outlines the functionality and configuration of Microbe, but here we shall look at the implementation in more detail, plus other features of zMob – this is the ABAP Development section after all!
As can be seen in the screen shot, the parameters of a report are mapped to the fields of a mobile application. The types of the parameters must be taken from the constants of the ZMOB class, and indicate the component or device data that the report would like to process.
Following are the available types for UI components and device integration:
Presents a map widget showing the current location of the device.
Presents a button that can be clicked to capture the value of a barcode using the camera.
Presents a button that can be clicked to capture audio from the device.
Presents a button that can be clicked to capture a photo using the camera.
Presents a button that can be clicked to capture a video using the camera.
Presents a simple checkbox component.
Presents a compass, which can be frozen on a heading by clicking.
Presents a date picker widget.
Presents a key-week picker widget.
Presents a box for text entry that grows as more text is added.
Presents a drop down list of items.
Presents an input field specialized for email input.
Presents an input field specialized for number input.
Presents an input field specialized for password input.
Presents one item from a group of radio buttons.
Presents a widget used to select an integer value between a maximum and minimum value.
Presents an input field specialized for telephone number input.
Presents an input field for plain text.
Presents an input field for plain text with help attached.
Presents a toggle button for On Off values.
Presents an input field specialized for http address input.
Returns the value of the device accelerometer at time of submit.
Returns the value of the device latitude at time of submit.
Returns the value of the device longitude at time of submit.
Returns the accuracy of the device longitude/latitude coordinates at time of submit.
Returns the value of the device altitude at time of submit.
Returns the accuracy of the device altitude sensor at time of submit.
Returns the value of the device heading at time of submit.
Returns the value of the device speed at time of submit.
Returns the timestamp at which the geolocation data was last updated.
Returns the device’s model or the name of the product.
Returns an ID unique to the device.
Returns version information for the operating system installed on the device.
Returns information on the operating system installed on the device.
Returns the configured user name for the SAP user using the device.
Start Of Selection
Once the user has entered data into the application, they click the “Submit to SAP” button and their form data is serialized. The data is then passed back to SAP and submitted to the corresponding report. The output from the report is sent back to the mobile application and rendered.
Tags within the returned data are interpreted and have special meanings.
- <link:…> will cause a line in the results to become a link to another ABAP report or HTTP address.
- <img:…> [planned] to allow specifying an inline image URL
- <html> [planned] to allow HTML output embedded within the application
- Other tags are planned for future implementation!
Example Source Code
Following is the code contained in zmicrobe_post and zmicrobe_index for the sample microblogging application Microbe. The code is simple and straightforward, and yet achieves impressive results thanks to zMob.
Note that because zmicrobe_index has no parameters defined, zMob skips an input screen and renders the results of calling start-of-selection directly for the user. The lines written to output are then shown to the user in a list view, including a link to the zmicrobe_post report.
* entry point into microbe mobile app
msg TYPE zmicrobe_msgs,
txt TYPE string.
WRITE ‘Welcome to the Microbe demo microblogging platform.’.
WRITE ‘See original implementation in reports ZMICROBE_INDEX and ZMICROBE_POST.’.
WRITE ‘Post a message <link:ZMICROBE_POST>’.
SELECT * FROM zmicrobe_msgs INTO msg
UP TO 20 ROWS
ORDER BY timestamp DESCENDING.
CONCATENATE msg–username ‘posted’ msg–message
INTO txt SEPARATED BY space.
* todo: include thumbnails <img:> – extend db..
IF sy–subrc NE 0.
* WRITE: ‘Be the first to post a message!’.
p_msg LIKE zmob=>ui_description,
p_usr LIKE zmob=>bg_user.
msg TYPE zmicrobe_msgs.
msg–timestamp = 0.
msg–username = p_usr.
msg–message = p_msg.
INSERT zmicrobe_msgs FROM msg.
COMMIT WORK AND WAIT.
‘Your message has been posted.’, /,
‘Back to Microbe <link:ZMICROBE_INDEX>’.
After activating a report and configuring user access for SAP users, the URL to your SAP system can be entered into the browser based emulator, and you will be able to see and interact with your mobile application, including logging the communication between SAP and the mobile application.
Your ABAP report will render within the emulator in the same way it would on a mobile device. This is a quick way to experiment and tweak your reports to make sure the correct data is being passed back and forth. It’s as simple as making a minor modification to your report, activating and refreshing the browser window to see the new changes take effect!
Once your application looks perfect, it can be distributed to test devices for hardware integration testing. Finally, using the user authorization system, the application can be pushed to the end user devices for use in production.
Currently we are in the process of beta testing the mobile clients for Android and iOS devices. If you are interested in participating in the beta testing phase, head on over to our Google+ Community for Beta Testing. Shortly we will also be looking for beta testers with Windows Phone and Blackberry devices.