Creating Apps in SAP Business Application Studio (Cloud Foundry)¶
Setting Up the Editor in SAP Business Application Studio (Cloud Foundry)¶
To create and develop applications using the Mobile Development Kit editor feature, you must first enable the feature on SAP Business Application Studio. It isn’t enabled by default.
Note
This procedure is applicable in the Cloud Foundry environment.
- Open
SAP Business Application Studioin any one of the supported browsers and log in with your credentials. - Choose
Create Dev Space. - Enter a name for the
Dev Space. - Select
SAP Mobile Application. -
Choose
Create Dev Space.Newly created development environment is listed in your
Dev Spaces. Choose the newly createdDev Spaceto launch the editor in SAP Business Application Studio.Note
If the development environment is in
STOPPEDstate. It is required to start the development environment to launch the editor.
You can now use the Mobile Development Kit editor feature to create and develop your project.
Creating or Editing App¶
Prerequisite¶
BTP Destination Prerequisite¶
Add one or more OData destinations depending on the business requirement. The OData destination must have the following additional properties:
HTML5.DynamicDestination=true(in order to access metadata from app studio)WebIDEEnabled=true(in order to be filtered by app studio)-
WebIDEUsage=odata_gen(in order to be filtered by OData usage)Note
To reuse a Cloud Foundry destination, add the following property
MobileEnabled = true. For more information, see Enabling Cloud Destinations. For a Cloud Foundry destination, access Cloud Foundry instead of mobile services for creating a project (As we can't access the Cloud Foundry destination from mobile services during design time).
Mobile Services Data Source Prerequisite¶
To retrieve OData collections while creating a new project or syncing a service in an existing project, you will need:
- SAP Business Application Studio Developer role if the SSO mechanism for the given mobile destination is set up as
No AuthenticationorBasic Authentication. - SAP Business Application Studio Administrator role if the SSO mechanism for the given mobile destination is set up with other authentication option. This is needed to get the JWT token.
Creating a New Project (Cloud Foundry)¶
Create a new Mobile Development Kit project by using the predefined templates provided with SAP Business Application Studio.
Note
The prerequisite is that you've configured a mobile application on mobile services.
Select the desired template type based on your requirements and the actions supported by each template, as described in the following table:
| Template Type | Logout/update | Online/Offline | List Detail Pages | Editable |
|---|---|---|---|---|
Empty |
Yes | No | No | No |
Base |
Yes | Yes | No | No |
List Detail |
Yes | Yes | Yes | No |
CRUD |
Yes | Yes | Yes | Yes |
- Log on to SAP Business Application Studio and navigate to your workspace.
- On the welcome screen, choose
New Project from Template. SelectMDK Apptemplate and chooseStart. -
If you are not logged in to Cloud Foundry, Cloud Foundry Sign In page will be appear. You can use the following methods to sign in:
-
Credentials
Enter your username and password. Click
Sign in. Select Cloud Foundry Organization and Space. If the login attempt fails, you will not be able to use Mobile Services Data Sources. -
SSO Passcode
Click the link to open a new browser page, choose to generate a temporary authentication code, copy the SSO Passcode and paste it back in the Cloud Foundry Sign In page.
-
-
In the
Basic Informationtab:Field Description MDK template typeBased on your requirement, select the MDK template typefrom the drop-down.Your Project NameEnter a project name. Your Application NameBy default, the project name is considered as the application name. However, you can also provide a different application name. Target MDK Client VersionBy default, the project uses MDK 6.0or later clients. However, you can select a previous version from the drop-down.Choose a target folderBy default, the target folder uses project root path. However, you can choose a different folder path. Choose
Next. -
In the
Service Configurationtab:Field Description Data SourceSelect a source from the drop-down. The available source types are: Mobile Services,BTP Destination,Service UrlandLocal File.Mobile Services LandscapeSelect your Mobile Services Landscapefrom the drop-down. This field appears only when you have selectedMobile Servicesas theData Sourcetype. There are three options available for landscape:standard,preview, andneo. The first two options are for the Cloud Foundry environment. If you haveMobile Services Previewedition available in yourCloud Foundryaccount, choosepreview. Chooseneofor the Neo environment.Application IdSelect an application from the drop-down. This is the application that you've created in mobile services. DestinationSelect a destination from the drop-down. Enter a path to serviceAppend a path to your OData service if required. Service UrlEnter the Service Url. This field appears only when you have selectedService Urlas theData Sourcetype.Destination NameEnter the DestinationNamein metadata.Choose XML odata metadata file from your local dev spaceSelect an XML file from the local files. This field appears only when you have selected Local Fileas theData Sourcetype.Language URLsap-languageis the default value. However, you can provide a different value.Enable offlineBy default, it's enabled. Select No to disable it. Choose
Next. -
In the
OData Collectionstab, select the required OData collections.
The newly created project is now available in your workspace. All the web related files are available in the Web folder.
The web folder consists of the following:
App_Resources/- Here you can customize the web resources like icon and images.config.json- Here you can customize the properties likeDefaultAppLanguageandApplicationDisplayName. For more information about configuring other properties, see Configure Web Specific Settings.
Project Settings¶
After you have created your new Mobile Development Kit project, a .project.json file is automatically created under the project folder. This file contains all the information you need to connect to mobile services.
{
"Credential": "cf",
"Onboarding": {
"Schema": "",
"URL": ""
},
"CF": {
"Target": "",
"Organization": "",
"Space": "",
"Deploy": {
"Destination": [
{
"CF": "",
"MDK": "",
"URL": ""
}
]
}
},
"MobileService": {
"Type": "standard",
"AdminAPI": "",
"AppId": "",
"Destination": []
},
"Build": {
"SourceMap": true,
"TSTarget": "es6",
"WMF": true
}
}
How to generate .project.json file if this file is missing in your project:
-
Command
MDK: DeployOn triggering this command, a prompt will ask you to enter required mobile services information. Then the
.project.jsonfile will be generated and deploy process will start. For more details, see Deploying to mobile services.Note
If the
.project.jsonfile is already in your project. It will deploy directly without any prompt. -
Command
MDK: Sync ServiceOn triggering this command, a prompt will appear asking you to enter required mobile services information. Then the
.project.jsonfile will be generated. Also the information in.project.jsonand local.xmlfiles will be updated.
User Settings¶
To display different features based on different schema version, you can set MDK: Show Features setting in SAP Business Application Studio Preferences.
-
In the
Filemenu , choosePreferencesandOpen Preferences, and then typeMDK, you will see all the Mobile Development Kit related settings. -
Find
MDK: Show Featuresand selectCurrent Schemafrom the drop-down.There are two options:
Show All: the default setting, all the features including the newly added will be provided in Mobile Development Kit projects.Current Schema: only supported features will be provided based on the specified schema version inApplication.appfile.
Reusing App Components¶
Create Component Integration Metadata (CIM)¶
As an app developer, you can reuse components that you have created for an app in your base (currently selected) app during the metadata building process.
Ensure that you have both the base app project and the component project in your workspace.
Create Component Integration Metadata (CIM) files using the editor in SAP Business Application Studio, to describe references between your base application and dependent components.
Accomplish integration between an app and a component by replacing definitions from one project with those of another, using integration points.
- In the File Explorer panel, right-click the
Application.appnode and selectMDK: New CIM. - Choose the desired Mobile Development Kit component app from the drop-down list under
Project Name. - Choose the application name from the drop-down list under
Application Name. When you choose a Mobile Development Kit component app, the property fieldCIM File Nameis automatically populated from theApplication.appfile of the selected component app. - Fill the
Component Versionfield manually if applicable. - Click
Finishto create theCIMfile. - To define an integration point on the new
CIMfile, clickAddand select a metadata object type from the drop-down. The available object types are:Action,Global,Page,Fragment,Rule,Service,i18n,Style,ExtensionandApplication. -
Under the newly opened Integration Point section, specify the
SourceandTargetmetadata and clickAccept.A new integration point is created. This means that the content of the source file will overlay the content of the target file at the time of metadata bundling.
Set Reference Applications¶
For a Mobile Development Kit component project imported into the editor, set the Reference Applications settings to ensure that there are no validation errors due to reference apps, and to use the metadata from these reference apps by browsing.
- Right-click on
Application.app, chooseOpen Withand then selectApplication Editor. - In
Editor Settingsection, set reference applications by clickingAddbutton.
To know more about the settings for component validation, see Application.app file.
Pages Map View¶
To check the pages map view, right-click on the Application.app, choose Open With and then select MDK Page Map.
Check Unused Files¶
Before publishing your project, you can check unused files within your project.
- Open a project in workspace.
-
In the
Viewmenu , chooseFind Command, and then typeMDK, and selectMDK: Check Unused Files.If you execute this command in the Projects Explorer, you will be asked to select an application (from existing projects list) where you want to list down the unused files for, then choose an application.
-
After the checking process completes, the unused files will be listed in the
Outputpanel. The messageThe check is done. Results are available in the 'MDK Extension' channel of the Output panel.will be prompted.
CSDL Check¶
You can check if the OData service built using CAP or any other framework is compliant with the OData standard. This ensures that you don't encounter any service-related issues at runtime.
Right-click on any .service file, choose MDK: CSDL Check Service.
Metadata and Script Migration¶
You can view changes, and selectively update your app metadata and script to the latest version.
Since Mobile Development Kit features are cloud-based editor, users who consume the metadata that is imported from the cloud may face issues on their devices. A migration report allows users to view changes in the metadata and in the scripts, before they choose to update their application. Thus, users can proactively inform the editor or client teams if issues are found.
The following files types are applicable for metadata migration:
ActionsGlobalsServicesPagesApplication
Note
It is recommended to perform metadata validation before migration to avoid failures due to errors in the code.
-
To trigger the migrate command, perform one of the following:
- In the File Explorer panel, right-click the
Application.appnode and selectMDK: Migrate. - In the
Viewmenu , chooseFind Command, then typeMDK, and selectMDK: Migrate. - Switch to the
MDK: Migrationperspective and click theMDK: Migratebutton next to the project. - Open
Application.appfile in application editor, if current schema version is not the latest, a message will show to ask you to migrate. You can clickStart to Migrate.
- In the File Explorer panel, right-click the
-
After the migration process is complete, a prompt message is displayed. Click the
Openbutton in the message to switch to theMDK: Migrationperspective, where all the pending files are listed in the project tree. - Click on the file name from the list. This will show all the differences between the file and the previous version. Here, you can verify the metadata changes. Only object property or value changes are highlighted as differences and formatting changes are ignored.
- Confirm the migration of the single file by clicking the check mark next to the file name. Click
Confirm Allnext to the project name to migrate all of the files.
The file is updated to the latest version, and it is no longer available in the list of files pending for migration.
Deploying the Project¶
To trigger the deploy command, perform one of the following sub-steps.
- In the File Explorer panel, right-click the
Application.appnode and selectMDK: Deploy. - Select
MDK: Deployin the command palette.
If you have not yet logged in to Cloud Foundry, you will be asked to log in first. After logging in, select your Organization and Space.
Note
After deployment, the deployment configurations will be stored in the mdk_deploy.json file in the .vscode folder under your workspace. This file is used for redeploying the project.
Deploying to Mobile Services¶
This topic describes the steps to deploy the generated bundle.js and bundle.js.map to SAP Mobile Services on Cloud Foundry. Please make sure you have been assigned the Space Developer role in your SAP BTP space.
- After selecting
MDK: Deploy, selectMobile Servicesas the target. -
For the first deployment, you will be prompted to choose
Mobile Services Landscape. You can choosestandard,previeworneo.Select an application from mobile services.
If you want to enable source for debugging, then, in the
Include source map file for debugging?deployment prompt, chooseYes.If the schema version of your project is lower than 6.0 and there are
.tsfiles in theExtensionsfolder, you will be prompted to choose the target client version.In the
.project.jsonfile,Buildsection contains target client option configuration. Check detailed explanation in the following table:TSTargetWMFTarget Client Version es6true MDK 23.4es6false MDK 6.xes5false MDK 5.xNote
If you choose
neoas the landscape, and it's Canary Neo mobile services, to make sure it can be accessed from SAP Business Application Studio, the mobile services Admin API needs to be configured in SAP Cloud Connector. If it's Factory Neo mobile services, then it doesn't need to be configured. -
If the application deploys successfully, a message with the current revision is displayed.
Note
After your first deployment, all the Cloud Foundry information and deployment information will be stored in the
.project.jsonfile in your project.If you want to input new configuration, you can remove it before next deployment.
Deploying to Cloud Foundry¶
- After selecting
MDK: Deploy, selectCloud Foundryas the target. - Enter the application ID.
-
Enter the application version. The default version is
1.0.0.If you want to enable source for debugging, choose
Yesin theInclude source map file for debugging?deployment prompt. -
For
MDK web runtime deployment option, you can choose:preview: to run your application in preview landscape and test it with the latest release.production: to run your application in the production landscape.
For any Mobile Development Kit major release, the preview web runtime will be updated first and, after two weeks, the production web runtime will be updated. For any Mobile Development Kit patch release, both the preview web runtime and production web runtime will be updated at the same time.
-
If the application deploys successfully, the
Deployed to Web application successfully!window is displayed. You can open the application by clickingOpen Application.
Deploying to Your Dev Space¶
- After selecting
MDK: Deploy, selectYour Dev Spaceas the target. - Enter the application ID.
-
Enter the application version. The default version is
1.0.0.If you want to enable source for debugging, choose
Yesin theInclude source map file for debugging?deployment prompt. -
For Mobile Development Kit web runtime deployment option, you can choose:
preview: to run your application in preview landscape and test it with the latest release.production: to run your application in production landscape.
For any Mobile Development Kit major release, the preview web runtime will be updated first and, after two weeks, the production web runtime will be updated. For any Mobile Development Kit patch release, both the preview web runtime and production web runtime will be updated at the same time.
-
If the application deploys successfully, the
Deployed successfully! Start running...window is displayed, and focus will automatically switch toDebugview from the left activity bar. - If there are previous running threads, stop them before running
WebApplicationFactory. If that runs successfully, theA service is listening to port 6004.message popup is displayed. - Click
Open in a New Tabto run the application.
Deploying to Mobile Services and Cloud Foundry¶
If you want to deploy your project to both Mobile Services and Cloud Foundry, select MDK: Deploy, and then select Mobile & Cloud as the target.
Redeploying the Project¶
If you want to perform the last deployment, select MDK: Redeploy in the command palette. If there is no last deployment configuration, it will trigger the MDK: Deploy command.
Developing App in SAP Business Application Studio¶
Features supported by Mobile Development Kit editor in SAP Business Application Studio are similar to the features supported by Mobile Development Kit extension for Visual Studio Code. Features supported are:
- Editing Metadata
- Validating Apps
- Creating and Bundling Extensions
- Component Application Development
- User Settings
- IntelliSense and Code Navigation Support for Extensions
Download or Export Mobile Development Kit Metadata¶
You can download or export Mobile Development Kit metadata to the local machine.
- In the project explorer, right-click on the project and choose
Download. - In the workspace, right-click on the empty area and choose
Download.