Skip to Content

Deploy CAP with SAP HANA Cloud project as MTA

Deploy your SAP HANA Cloud and Cloud Application Programming Model application as a Multi-Target Application (MTA) to SAP BTP, Cloud Foundry runtime
You will learn
  • You will prepare our project for deployment via Multi Target Application to SAP BTP, Cloud Foundry runtime
  • You will use the Cloud MTA Build tool to package your project for deployment
  • You will deploy your application to SAP BTP, Cloud Foundry runtime
jung-thomasThomas JungMay 6, 2022
Created by
March 30, 2021


  • This tutorial is designed for SAP HANA Cloud. It is not designed for SAP HANA on premise or SAP HANA, express edition.
  • You have completed all previous tutorials in this Mission or have at least developed up to the point of adding User Authentication to your application.

Note: This is an optional tutorial as part of this mission on SAP HANA Cloud plus Cloud Application Programming Model for those that want to fully deploy like a production application. There are limited resources allocated in an SAP BTP trial or free tier account and you should consider deleting this content after deploying to avoid using up all of these resources.

  • Step 1
    1. In this tutorial mission we’ve combined several different development types (HANA, CAP, Fiori) and wizards into a single project. This has required several workarounds to the project structure to make it all work together. Furthermore we will need a few more adjustments before we can deploy the complete application.

    2. We will begin with the xs-security.json file. We need to make one adjustments to this file. Remember that we added the oauth2-configuration section to allow authentication redirection from the SAP Business Application Studio testing. We want to remove this configuration so that we will instead get the standard UAA oAuth configuration. The xs-security.json file should now look like this:

        "xsappname": "myhanaapp",
        "tenant-mode": "dedicated",
        "description": "Security profile of called application",
        "scopes": [
            "name": "uaa.user",
            "description": "UAA"
        "role-templates": [
            "name": "Token_Exchange",
            "description": "UAA",
            "scope-references": [
    3. The rest of the adjustments we need to make are all in the mta.yaml file in the root of the project. This is the file that will control the build and deployment of the application.

    4. The first adjustment we want to make is to the database module section. We added default-env.json and .env files to the project so that we could deploy and test from the SAP Business Application Studio. However we don’t want these files to be present in a “real” deployment, instead getting configuration from the bound service instances. Therefore we can tell the builder to exclude these files from this module. That way we can keep these files in our project for future testing and development but ensure that they don’t accidentally make it into a production deployment.

      mta.yaml database module build parameters
    5. The next adjustment to mta.yaml is rather substantial. There are different ways to deploy the UI content of our project. We could use standalone application router, managed application router, Fiori launchpad, and/or the HTML5 repository. The wizard that we’ve used previously setup our project to use a standalone application router but also the HTML5 repository. For your project needs you might decide on different combination of these options and you should explore the impact that each choice has on your deployment approach. However for this tutorial, we’ve chosen to stay with the standalone application router, but not to use the HTML5 repository. This is a choice that simplifies the setup and is good for small scale applications where you don’t mind keeping the UI5 content local within the application router service itself. Therefore we can simply remove all the references and dependencies to the HTML5 Repository and UI Deployer in your mta.yaml file.

      Remove UI Deployer and HTML5 Repo from mta.yaml services

      Note: If you wanted to keep the HTML5 repository, then some additional changes to the build parameters of the UI Deployer and to the xs-app.json of the application router would be necessary.

    6. The last adjustment is a continuation of the previous step. We need to also remove all references to the HTML Repo and UI Deployer from the resources section of the mta.yaml file as well.

      Remove UI Deployer and HTML5 Repo from mta.yaml resources
  • Step 2
    1. Now that all of our project adjustments are complete, we can use the Cloud MTA Build tool to package the project for deployment.

    2. Open a terminal window in SAP Business Application Studio and from the root folder of your project issue the command mbt build

      mbt build
    3. This will take several minutes as various build steps are performed (such as running npm install on each module) to prepare the project for deployment. The output of this command will be a zip archive with the extension MTAR in a new folder of your project named mta_archives.

      mtar in project output
    4. Not required as part of the deploy process, but it might be interesting to see what is inside this MTAR file. You can download the file to your desktop and then open with an zip archive tool. In the root of the zip you will find folders (with zip files inside them) for the three modules we described in your mta.yaml file. Looking at the MTAR file in a zip utility is a good way to double check and make sure that your content is structured the way you wanted (and that your build-parameters exclusions worked) before attempting to deploy to Cloud Foundry.

      MTAR Inner Content
  • Step 3
    1. Now we are ready to deploy our entire project to SAP BTP, Cloud Foundry runtime. Although you can perform the deployment from the command line using the cf deploy command, you can also trigger it from the SAP Business Application Studio just by right mouse click on the MTAR file and choosing Deploy MTA Archive.

      Deploy MTA Archive
    2. If you start the deploy and immediately receive this error don’t be alarmed.

      Deploy Error

      This just means that your login to Cloud Foundry has expired (which it does daily). From the Business Application Studio you can click on the Targeting CF section in the bottom bar or from any terminal window use the cf login command to renew your login credentials. Then you can repeat the deployment.

    3. Otherwise your deploy should continue as normal. It will take several minutes to complete. You should see services being created from the resources section of the mta.yaml first then applications from the modules section of the mta.yaml.

      Deploy log
    4. Upon successful completion of the MTAR deployment, you should be able to navigate to your space and applications in the SAP BTP Cockpit and see the three deployed applications. It is normal that the database deployer would be in a state of stopped. A deployer is an application that only needs to run upon deployment to send it’s content somewhere (SAP HANA in this case). The application then shutdown and no longer consume resources.

      SAP BTP Cockpit Applications after Deploy
    5. If either of other two application have bad requested state or their instances are not 1/1 then there may have been an error during deployment. If so continue to the next step where we will see how to view the Logs.

    6. If you click on the name of the app, you will navigate to a detail screen for each application. From here you can access the URL for your application or view the Logs if there was some startup error.

      SAP BTP Cockpit application detail
    7. Remember to test via the Application Router as only that application will have the redirect to the Login Screen to generate the security token. But other than the different URLs everything should work the same as when we tested with authorization from the SAP Business Application Studio. Also because the database container was deployed to a new HDI container instance; you will need to return to the Database Explorer, connect to this new instance and load the data from CSV files.

Back to top