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:
UI Components
ZMOB=>UI_MAP
Presents a map widget showing the current location of the device.
ZMOB=>UI_CAPTURE_BARCODE
Presents a button that can be clicked to capture the value of a barcode using the camera.
ZMOB=>UI_CAPTURE_AUDIO
Presents a button that can be clicked to capture audio from the device.
ZMOB=>UI_CAPTURE_PHOTO
Presents a button that can be clicked to capture a photo using the camera.
ZMOB=>UI_CAPTURE_VIDEO
Presents a button that can be clicked to capture a video using the camera.
ZMOB=>UI_CHECKBOX
Presents a simple checkbox component.
ZMOB=>UI_COMPASS
Presents a compass, which can be frozen on a heading by clicking.
ZMOB=>UI_DATE
Presents a date picker widget.
ZMOB=>UI_KEYWEEK
Presents a key-week picker widget.
ZMOB=>UI_DESCRIPTION
Presents a box for text entry that grows as more text is added.
ZMOB=>UI_DROPDOWN
Presents a drop down list of items.
ZMOB=>UI_EMAIL
Presents an input field specialized for email input.
ZMOB=>UI_NUMBER
Presents an input field specialized for number input.
ZMOB=>UI_PASSWORD
Presents an input field specialized for password input.
ZMOB=>UI_RADIO
Presents one item from a group of radio buttons.
ZMOB=>UI_SLIDER
Presents a widget used to select an integer value between a maximum and minimum value.
ZMOB=>UI_TELEPHONE
Presents an input field specialized for telephone number input.
ZMOB=>UI_TEXT
Presents an input field for plain text.
ZMOB=>UI_TEXT_HELP
Presents an input field for plain text with help attached.
ZMOB=>UI_TOGGLE
Presents a toggle button for On Off values.
ZMOB=>UI_URL
Presents an input field specialized for http address input.
Device Properties
ZMOB=>BG_ACCELEROMETER
Returns the value of the device accelerometer at time of submit.
ZMOB=>BG_GEOLOC_LATITUDE
Returns the value of the device latitude at time of submit.
ZMOB=>BG_GEOLOC_LONGITUDE
Returns the value of the device longitude at time of submit.
ZMOB=>BG_GEOLOC_ACCURACY
Returns the accuracy of the device longitude/latitude coordinates at time of submit.
ZMOB=>BG_GEOLOC_ALTITUDE
Returns the value of the device altitude at time of submit.
ZMOB=>BG_GEOLOC_ALTITUDEACCURACY
Returns the accuracy of the device altitude sensor at time of submit.
ZMOB=>BG_GEOLOC_HEADING
Returns the value of the device heading at time of submit.
ZMOB=>BG_GEOLOC_SPEED
Returns the value of the device speed at time of submit.
ZMOB=>BG_GEOLOC_TIMESTAMP
Returns the timestamp at which the geolocation data was last updated.
ZMOB=>BG_DEVICE_MODEL
Returns the device's model or the name of the product.
ZMOB=>BG_DEVICE_UUID
Returns an ID unique to the device.
ZMOB=>BG_DEVICE_VERSION
Returns version information for the operating system installed on the device.
ZMOB=>BG_PLATFORM
Returns information on the operating system installed on the device.
ZMOB=>BG_USER
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
REPORT zmicrobe_index.
DATA:
msg TYPE zmicrobe_msgs,
txt TYPE string.
START-OF-SELECTION.
WRITE 'Welcome to the Microbe demo microblogging platform.'.
NEW-LINE.
WRITE 'See original implementation in reports ZMICROBE_INDEX and ZMICROBE_POST.'.
NEW-LINE.
WRITE 'Post a message <link:ZMICROBE_POST>'.
NEW-LINE.
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..
WRITE txt.
NEW-LINE.
ENDSELECT.
IF sy-subrc NE 0.
* WRITE: 'Be the first to post a message!'.
ENDIF
REPORT zmicrobe_post.
PARAMETERS:
p_msg LIKE zmob=>ui_description,
p_usr LIKE zmob=>bg_user.
START-OF-SELECTION.
DATA:
msg TYPE zmicrobe_msgs.
msg-timestamp = 0.
msg-username = p_usr.
msg-message = p_msg.
INSERT zmicrobe_msgs FROM msg.
COMMIT WORK AND WAIT.
write:
'Your message has been posted.', /,
'Back to Microbe <link:ZMICROBE_INDEX>'.
Debugging
The zMob emulation system can be used to test your installation and your own reports from within the browser. (It is also available in the Google Chrome store for free.)
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.
Mobile Clients
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.
Links
- Source code on the zMob project page: https://bitbucket.org/zmob/sap
- Microbe project: https://code.google.com/p/microbe
- Keep up to date on the zMob project on Google Plus and Facebook.
- Become a beta tester for the latest version of the mobile apps.