Wednesday, June 19, 2013

Using Composite operations in SAP Mobile Platform to improve performance

SAP Mobile Platform is SAP’s mobile application development platform. With SMP you are able to build complex mobile applications quickly for multiple devices. SMP provides out of the box synchronisation capabilities and security features. 

With the release of SUP 2.2 PL3 there was a new feature called “Composite operation”. This nice new feature can be used to get better performance in your SUP MBO application. With this feature you are able to split a large MBO in multiple smaller MBO’s, but still use the larger (webservice) operations.


With the composite operation you can create a kind of lazy loading if you have MBO’s with a lot of data or have large attributes that are only needed for detail views. One advantage that you will create with this approach is that the page size of your package will be smaller and improve synchronisation performance. On the device, for example an iOS application, most of the time there will be a list view, when splitting an MBO into smaller MBO’s and only keep the attributes for showing, sorting, grouping and searching in the “Main” MBO will speed up your application.

The composite operation is designed to be used for one-to-many relationship. Like a sales order with order items. When you update your sales order in the same request you can also update your order items with that same operation. This way you will keep you data consistence.

The “Composite operation” is a nice new feature and we are going to show how to use it while building your business model in de SMP mobile SDK. For this example I used the sample database provided with SMP and created a small webservice for the customer table for the operations.

Let’s create a model in the SMP mobile SDK. Create a new Mobile Application project and drop the customer table from the sample database to the diagram and only map the id, fname & lname attributes to the main MBO. Drop another customer in your diagram and map the primary key and all other fields to the second MBO. Create a relationship between these MBO’s on the primary key.





For this example I created a one-to-one relationship and checked the 'Composite' box.



 

After adding the relationship we define a new operation. The trick here is to add an XSLT for each MBO. For this example I only checked the used attributes for each MBO by the creation of the XSLT.



After adding the XSLT’s we can map the input and output parameters to the MBO’s.





When the mapping is done this will result in the following model. We only have to create an operation on the “Main” MBO.

 

As I mentioned the composite operation was designed for one-to-many relationships, but this way it can improve performance as well!

3 comments:

  1. Hi Jeroen, thanks for your blog! I would like to use a composite operation in order to read data via RFC and update multiple MBOs in the CDB with the results. In my cache policy I have selected "Immediately update the cache" and "Apply merge of operation input/output". The first time I invoke the operation everything works fine, however in subsequent invocations the error message "SQL Anywhere Error -196: Index '_BUSINESS_PK_INDEX_d1_testdcncompositembo__55737' for table 'd1_testdcncompositembo__55737 would not be unique". Had you a similar problem?
    Regards, Matthias

    ReplyDelete
    Replies
    1. Matthias you have to be assured that on all the MBO's you have the same PK. Also the RFC need to return the PK when doing the update call (have you connected the response value?).
      Are U using the composite operation for a 1-to-many or a 1-to-1 relationship? We had some issues with a 1-to-1 solution, where we needed a patch from SAP.

      Delete
  2. Hi Matthias, which version of SMP are you using? There are some EBF's regarding lost of primary key by rebinding the MBO (EBF 20340 2.1.3 sp1 for example).
    Can you check if the findByPrimaryKey is still correct binded?

    ReplyDelete