Technology Blogs by SAP
Learn how to extend and personalize SAP applications. Follow the SAP technology blog for insights into SAP BTP, ABAP, SAP Analytics Cloud, SAP HANA, and more.
cancel
Showing results for 
Search instead for 
Did you mean: 
nhatdoan
Advisor
Advisor
780
My name is Nhat Doan. I am currently in SAP Student Training and Rotation (STAR) Program. In my first rotation, I have a chance to join CoE Mobile & UX team. I have learned a lot of things especially about current developments in mobile technology. Today, smartphones become essential for daily life. Businesses are using mobile applications to serve their clients and they will see many benefits such as brand building, customer connection, and profit boosts. I would like to share some topics concerning mobile development.

  1. Build ProductCatalog application with AppGyver and Northwind OData service.

  2. Build ProductCatalog application with SAP MDK and Northwind OData service.

  3. How to style the MDK application.

  4. How to run MDK application on virtual device and override resources.

  5. How to reads log, traces issue, and measures performance for MDK application.


How to reads log, traces issue, and measures performance for MDK application

For this blog, I would like to share how I use Android Studio to read logs, traces issue, and measure the performance for MDK application.

Read log

Set up to run the application on virtual device.  Open Android Studio, select Logcat tab at the bottom of the application. Select the package (AppId) that we want to see the log.


Figure 1: Use Logcat to see the log of MDK application


Trace issue

Here is an example of updating a record unsuccessful. The application shows the error.


Figure 2: The application show error when updating a record


Go to Logcat and check the log. We can see the error log in the Logcat.


Figure 3: The error log in Logcat


Based on the log error, the issue is we update the record using PATH method (The UpdateValue in action file is Merge). However, the oData service does not support PATCH. We need to change the UpdateMode value  from Merge to Replace.


Figure 4: Change UpdateMode to Replace


Now the application can update the records successfully.


Figure 5: The application run normally after fixing the bug


Performance measure

This example shows how to measure the time the application performs an action to update a record and the actual time of oData service takes to update the record. It will be very useful for analyzing performance issue of MDK application.

We can use the rule file to log the time of an action. The code below is the content of ExecuteUpdateCartItem.js
export default async function ExecuteUpdateCartItem(context) {
try {
console.log('ExecuteUpdateCartItem start')
console.time('ExecuteUpdateCartItem')
return await context.executeAction({
'Name': '/ProductCatalog2/Actions/Cart/UpdateCartItem.action'
})
} catch (e) {
console.error(e);
} finally {
console.timeEnd('ExecuteUpdateCartItem')
console.log('ExecuteUpdateCartItem end')
}
}

This rule file will be called when we update a record instead of using UpdateCartItem.action directly.


Figure 6: Use rule file to have the log


Run the application and check the log. Now we have the time for performing UpdateCartItem.action in the log.


Figure 7: The time of executing UpdateCartItem.action


We can use App Inspection in Android Studio to measure the time of calling oData service to update a record. Click on App Inspection at the bottom of Android Studio. Select the package that we want to inspect (AppId). And select Network Inspector tab. Select the timeline that we want to inspect.


Figure 8: The time of sending and receiving data


We can use the time from the log file and from App Inspection for analyzing the performance of MDK application.

Conclusion

We have just finished reading logs, analyzing issues, and tracing performance for MDK application. It will be useful in the future for fixing bug, or analyzing the performance issue.

Please let me know your feedback, questions in the comments. I would be happy to get back to you.