Installing the Tools¶
SAP Business Application Studio¶
From the SAP Business Application Studio home page, click on the Create Dev Space button.
-
Enter a
Dev Spacename, e.g.test. -
Select the
SAP Mobile Applicationkind of application. -
Click on the
Create Dev Spacebutton. -
Wait while the
Dev SpaceisSTARTING. -
When the
Dev SpaceisRUNNING, click on the underlinedDev Spacename. -
From the
Terminalmenu, select theNew Terminaloption. -
After the
$prompt in theTerminalwindow, enter amkdircommand to create a project folder. For example:mkdir ~/projects/test -
From the
Filemenu, select theOpen...option, and use it to open the project folder that was created in theTerminalwindow in the previous step.
Note
The Visual Studio Code Extension, Java Development Kit, Apache Maven, Apache Tomcat and Cloud Foundry CLI are preinstalled in SAP Business Application Studio, so the corresponding installation sections in this document can be skipped. The subsequent sections for Visual Studio Code Commands and Visual Studio Code Tasks are still applicable to SAP Business Application Studio.
Visual Studio Code Extension¶
Visual Studio Code can be used to access the mobile back-end tools on a desktop computer system.
-
Install
Visual Studio Codefor Windows, Mac or Linux. -
Install the
Visual Studio Code extension for mobile back-end tools(vsc-extension-mbt). -
The optional
SAP Mobile Services OData CSDL modelerextension enables visualization of CSDL XML files (where the file name extension ends with is.csdl.xml). -
The optional XML Language Support by Red Hat extension enables enhanced text editing of XML documents (where the file name extension is
.csdl.xmlor.xml). Refer to the Conventions for OData Metadata describing thexmlns:xsiandxsi:schemaLocationattributes.
Install Java Development Kit¶
-
Download and install the SapMachine Java Development Kit (JDK). Ensure that the JDK version that you download and install is not for a more recent version of Java than is supported by your intended target Java application server, and is also at least Java 11.
-
Ensure that the
JAVA_HOMEenvironment variable is set in thePATHand that it refers to the correct JDK installation.Mac/Linux Terminal:
$JAVA_HOME/bin/java -versionWindows Command Prompt:
%JAVA_HOME%\bin\java -version -
Restart Visual Studio Code (if running) so it can pick up the
PATHchange. Running thejava -versioncommand in a Visual Studio Code Terminal will verify that thePATHsetting has been picked up.
Install Apache Maven¶
-
Ensure that the
mvncommand is available in thePATHby issuing the following command in a Windows Command Prompt or Mac/Linux Terminal.mvn -help -
Restart Visual Studio Code (if running) so it can pick up the
PATHchange. Running themvn -helpcommand in a Visual Studio Code Terminal will verify that thePATHsetting has been picked up.
Install Apache Tomcat¶
This step is optional, but may be helpful for local testing, or on-premise production deployment, of your generated OData service.
-
Download and install Apache Tomcat 9 (for Java EE), or preferably Apache Tomcat 10+ (for Jakarta EE).
If you will use Apache Tomcat 9 (for Java EE), you should add the
-javaxoption to theserver-app.optionsfile that will be generated later when you create the OData service. -
Note that the following instructions refer to
CATALINA_BASEandCATALINA_HOMEwhich are described in Tomcat Directories and Files. -
Configure Tomcat as appropriate to your local environment. To enable generated OData services to access your target database, create the
$CATALINA_BASE/conf/jdbc/DefaultDB.propertiesfile with configuration parameters as defined by Apache Commons DBCP. You might need to create the$CATALINA_BASE/conf/jdbcfolder if it doesn't already exist.The following example configures Tomcat to access a local SAP HANA Express Edition database.
driverClassName=com.sap.db.jdbc.Driver url=jdbc:sap://hxehost:39013?autocommit=true¤tschema=myschema username=SYSTEM password=MyHanaPasswordTo obfuscate (hide) the password, see Local Password Obfuscation.
Alternatively you may define a
jdbc/DefaultDBResource in$CATALINA_BASE/conf/config.xml. -
Copy the JDBC driver file(s) for your database (e.g.
ngdbc.jarfor SAP HANA) to the$CATALINA_HOME/libfolder (or the$CATALINA_BASE/libfolder).
Note
Steps 3 and 4 above can be deferred if you will initially use the -h2db option
for an Embedded H2 Database (for testing only).
Install Cloud Foundry CLI¶
If you wish to enable command-line deployment to SAP Business Technology Platform (Cloud Foundry environment), including when using Visual Studio Code Tasks, install the Cloud Foundry Command Line Interface.
Ensure that the cf command is available in the PATH by issuing the following
command in a Mac/Linux Terminal or Windows Command Prompt.
cf help
- Restart Visual Studio Code (if running) so it can pick up the
PATHchange. Running thecf helpcommand in a Visual Studio Code Terminal will verify that thePATHsetting has been picked up.
Note
Before attempting deployment to Cloud Foundry, you should use the cf login command to connect and login to your Cloud Foundry space. This needs to be repeated whenever the login expires (e.g. daily).
Visual Studio Code Commands¶
Note
This section is also applicable to SAP Business Application Studio.
The mobile back-end tools extension provides two additional commands to the Command Palette,
accessed by View > Command Palette...
-
MBT: New OData CSDL document (metadata)-
Command parameters:
- Schema namespace
- Namespace alias
- Metadata file name
-
You might already have a CSDL document, in which case place a copy of it into your project's root folder instead of creating a new document, and refer to the Conventions for OData Metadata describing the
xmlns:xsiandxsi:schemaLocationattributes which enable the XML Language Support by Red Hat extension to locate the XML Schema files for OData CSDL validation. -
Use the file extension
.csdl.xmlfor OData CSDL XML files. -
The
SAP Mobile Services OData CSDL modelerextension allows visualization of an OData CSDL XML file. Open it using the context menu (usually right mouse click),Open With... OData CSDL Modeler. -
Once you have created the CSDL document you can use the project file creator.
-
-
MBT: Create Mobile Backend Server Project-
Command parameters:
- Application Folder
- Metadata File
- Application Name
- Database Type
- Database Instance
- Enable XSUAA (for security)
-
After entering the requested information, this command should display progress information in a Terminal window and eventually show "BUILD SUCCESS".
-
The generated project files include:
.vscode/tasks.json- Java source files which can be edited if customization is required.
- Various
.optionsfiles containing parameters and settings for the generated server.
-
Once you have created the project files, you can use
Terminal > Run Taskto invoke the service generator tool to build or deploy the OData service. You can make changes to the service metadata or customize previously source code or.optionsfiles, then run the same task again to rebuild or redeploy the service.
-
Visual Studio Code Tasks¶
Note
This section is also applicable to SAP Business Application Studio.
You can access the service generator tool through tasks.
By default, the generated project includes a tasks.json file which defines several tasks:
-
build-mobile-server- regenerates (as needed) and re-compiles the source files into a WAR file which can later be deployed into SAP Business Technology Platform Cloud Foundry. -
deploy-mobile-server- regenerates (as needed) and re-compiles the source files into a WAR file, and deploys it into SAP Business Technology Platform Cloud Foundry. -
preview-mobile-server- regenerates (as needed) and re-compiles the source files into a WAR file and deploys it into a local Apache Tomcat server.
The generated WAR file will be located in your project's deploy subfolder. (Maven builds typically use the target subfolder, but that is used by Visual Studio Code's auto-build features, so the deploy folder is used to avoid conflicts between auto-builds and task-initiated builds).
Generated Options Files¶
By default, the generated project includes several .options files, which you can customize as needed.
-
build-cloud.options- build options for Cloud Foundry. -
build-local.options- build options for Local Preview. -
deploy-cloud.options- deployment options for Cloud Foundry. -
deploy-local.options- deployment options for Local Preview. -
server-app.options- server name and version. -
server-db.options- options for target database. -
server-log.options- options for debug / trace logging.
Please refer to Service Generator Tool Options for information on the available generation options. Add any additional required options to whichever .options file(s) seem most appropriate.
Any line in an options file starting with a "#" sign is treated as a comment.