Quick Start with the Mobile Development Kit (MDK)
- How to create an MDK sample app using a template in SAP Business Application Studio
- How to deploy an MDK app to Mobile Services and run it in mobile client
- How to deploy an MDK app to Cloud Foundry and run it as a Web application
- Step 1
This step includes creating the mobile development kit project in the editor.
Launch the Dev space in SAP Business Application Studio.
Click Start from template on Get Started page.
If you do not see the
Get Startedpage, you can access it by typing
>get startedin the center search bar.
Select MDK Project and click Start.
If you do not see the MDK Project option check if your Dev Space has finished loading or reload the page in your browser and try again.
This screen will only show up when your CF login session has expired. Enter your login credentials, click Sign in. After successful signed in to Cloud Foundry, select your Cloud Foundry Organization and Space where you have set up the initial configuration for your MDK app and click Apply.
In Basic Information step, provide the below information and click Next:
MDK Template Type
CRUDfrom the dropdown
Your Project Name
Provide a name of your choice.
MDKAppis used for this tutorial
Your Application Name
<default name is same as project name, you can provide any name of your choice>
Target MDK Client Version
Leave the default selection as
MDK 6.0+ (For use with MDK 6.0 or later clients)
Choose a target folder
By default, the target folder uses project root path. However, you can choose a different folder path
In Service configuration step, provide the below information and click Next:
Mobile Servicesfrom the dropdown
Mobile Services Landscape
standardfrom the dropdown
com.sap.mdk.demofrom the dropdown (this app was configured as per this tutorial)
SampleServiceV2from the dropdown
Enter a path to service
Leave it as it is
It’s enabled by default
Regardless of whether you are creating an online or offline application, this step is needed for app to connect to an OData service. When building an MDK Mobile application, it assumes the OData service created and the destination that points to this service is set up in Mobile Services. For MDK Web application, destination is set up in SAP BTP cockpit.
Since we have Enable Offline set to Yes, the generated application will be offline enabled in the MDK Mobile client and will run as online in Web environment.
In the Data Collections step, select
SalesOrderItems. Click Finish to complete the project creation.
After clicking Finish, the wizard will generate your MDK Application based on your selections. You should now see the
MDKAppproject in the project explorer.
- Step 2
This is how the project structure looks like within the workspace.
These are the metadata definitions available in the editor and the format in which these metadata definitions are stored in the editor. Just to brief on some of these:
InitializeOffline.action: For Mobile applications, this action binds the application to the Mobile Services Offline OData server and downloads the required data to the offline store on the mobile device. For Web applications, it will initialize the service to be consumed in online mode.
UploadOffline.action: These actions are applicable to Mobile client only. Using app initialization, data is downloaded to the offline store. If you want to have the application download any updated data from the backend server or upload changed data to the backend server, these actions will be needed.
Success & Failure Message action: Here are some messages showing up in the app on a successful or failure of data initialization, sync etc.
Main.page: This is the first page of your MDK application that is shown. For this application you will use this as a launching page to get to application functionality.
OnWillUpdate.js: This rule is applicable to Mobile client only. MDK applications automatically download updates and apply them to the client without the end-user needing to take any action. The
OnWillUpdaterule empowers the user to run business logic before the new definitions are applied. This allows the app designer to include logic to prompt the user to accept or defer applying the new definitions based on their current activity. For example, if the end-user is currently adding new customer details or in the middle of a transaction, they will be able to defer the update. The app will prompt again the next time it checks for updates.
Web: In this folder, you can provide web specific app resource files and configurations.
Application.app: this is the main configuration file for your application from within SAP Business Application Studio. Here you define your start page (here in this tutorial, it is main.page), action settings for different stages of the application session lifecycle, push notifications, and more.
Open the application settings in the application editor by clicking the
- Step 3
So far, you have learned how to build an MDK application in the SAP Business Application Studio editor. Now, you will deploy the application definitions to Mobile Services and Cloud Foundry to use it in the Mobile client and Web application respectively.
Application.appand select MDK: Deploy.
Select deploy target as Mobile & Cloud.
MDK editor will deploy the metadata to Mobile Services (for Mobile application) followed by to Cloud Foundry (for Web application).
First web deployment takes 2-3 minutes as it creates five service instances for the application, you can find these details in space cockpit.
HTML Repo host
HTML repo runtime
You should see successful messages for both deployments.
- Step 4
SAP Business Application Studio has a feature to display the QR code for onboarding in the Mobile client.
Application.appto open it in MDK Application Editor and then click the Application QR Code icon.
The On-boarding QR code is now displayed.
Leave the Onboarding dialog box open for the next step.
- Step 5