This framework is called the Mobile Client Application Framework, or in short: mCAF. mCAF is based on the Model View Controller Concept (MVC) that most experienced developers will have already heard of and in a lot of cases already have some experience with. According to the Model View Controller design pattern an application consists of a model layer, a view layer and a controller layer.
The goal of the MVC concept is to separate data (Model) and user interface (View) concerns, so that changes to the user interface do not impact the data handling, and that the data can be reorganized without changing the user interface. The Model-View-Controller design pattern solves this problem by decoupling data access and business logic from data presentation and user interaction, by introducing an intermediate component: the Controller.
The View layer displays context data provided by the controller layer. View files describe the navigation flow and are in XML format. The different application screens are a result of compiling the JSP pages that actually hold the design of the screens. One advantage of this approach is that customers can use their own JSPs without any need to recompile the code.
The Controller layer is made up of Controllers which are Java classes. For each JSP there is a java class – a view controller – that implements methods for the different events that can be triggered from the JSP page. The view controller accesses the model layer and uses business objects from the model layer as transport objects to and from the context of a view. View controllers are responsible for preparing the context of a view, controlling application navigation by handling view events from JSPs and for processing user input. Another kind of controllers, custom controllers, are responsible for sharing data among views and components.
The Model Layer consists of the business logic process and business objects. The business logic process encapsulates related business logic and is the entry point for view controllers and customers who would like to reuse the business logic.
After looking at some of the theoretical background let’s have a look at an example of an enhancement for the SAP xApp Mobile Time and Travel.
We would like to add a corporate policy page on which our employees can check on our travel policy to our start page. You can find this example including a detailed description of all necessary steps in the MTT 2.0 Enhancement Guide. In addition to that this guide covers a large number of topics regarding the enhancement of xMTT. There are similar guides available for the other applications as well.
As you can see in the screenshot above a link has been added to the start page of Mobile Travel 2.0. Clicking this link will take you to the Corporate Policy page that you can see below.
So, in order to achieve our enhancement, what do we have to do ? How many steps does it take ? Is it difficult ?
The image below gives you an overview of the JSPs, the java classes and the view files that you have to work on.
The necessary steps are as follows (once again, you can find all the details including screenshots of the steps in the MTT 2.0 Enhancement Guide so that I will stay on a high level here and spare you the details):
1. Create a CustomHome.jsp by copying Home.jsp. Perform the required changes to the graphics in the custom jsp.
2. Create a View file CustomHome.view. Add your new event to the custom view file.
3. Create a CustomHomeController by extending HomeController. Do the necessary changes to CustomHomeController.
4. Create a view.configure file and tell the application to use CustomHome.view instead of Home.view
5. Create the CustomerCorporatePolicy.jsp page
6. Create a controller named CustomCorporatePolicyController.java
7. Create the view description file CustomCorporatePolicy.view
So it took 7 steps to enhance our MTT application by adding a corporate policy page. And I don’t think that it was too difficult even if the steps listed above don’t contain the details.
People could now claim that seven steps to add just another page is a lot compared to 2 steps required for doing that in plain html (create a new HTML page, create a link to it on the old page).
What you have to keep in mind though is the fact that the next time somebody updates your HTML pages you have to do all your changes again since there is no enhancement concept in place. And the next time somebody does an update to your html pages you have to do your changes again. And again. And again.
The goal of mCAF is to address this – so there might be some more steps required at first but it results in less steps in the long run.
I hope that I was able to give you a first impression on how to enhance a mobile application using mCAF and that I have motivated you to have a look at the extensive documentation available.
Give it a try and enjoy the new freedom that mCAF gives you in adjusting SAP mobile apps to your specific needs – just sticking to enhancements, without having to do modifications.