How to Deploy SAP RAP App to SAP BTP

How to Deploy SAP RAP App to SAP BTP

SAP RAP

Following our SAP RAP series, where we built managed and unmanaged RAP applications, we published their respective service bindings and previewed the apps. However, the URLs we used were for development, not for end-users.

Both applications were published locally, so to make them accessible to your end-users, you need to deploy them.

For this exercise, we will deploy the Bank Management app that we built in this tutorial: SAP RAP Unmanaged Scenario with EML: Implement CUD on Standard BO.

We'll use SAP Business Application Studio (BAS) for the deployment process, and the final application will be added to a site created in SAP BTP Work Zone. This site functions like an SAP Fiori Launchpad, where all deployed applications are made available for end-users.

Since we've already built two RAP apps, you likely have some roles for the BTP ABAP environment. Now, we'll need a few more for the deployment process itself.

You will need to use three key SAP BTP services:

  • Cloud Identity Services

  • SAP Business Application Studio (now part of SAP Build Apps)

  • SAP Build Work Zone, standard edition

SAP BTP Services


Setup the Required BTP Services

To speed up the setup, follow the steps in this video tutorial by SAP: Set Up SAP Build Apps on an SAP BTP Trial Account. It shows you how to subscribe to SAP Build Apps using a booster, which automates multiple configuration steps.

Booster

You only need to follow the tutorial until the services are available for use.

After following above steps, if you can't find SAP Business Application Studio (BAS) under Subscriptions, you can subscribe to it separately from the Service Marketplace.

SAP BAS Subscribe

Once it's available, click on the SAP BAS service link. If you get an authorization error, make sure you have the "SAP Business Application Studio Developer" role assigned to your user.

Roles for BAS

Assign the Business_Application_Studio_Developer and Launchpad_Admin role collections to your user.

If you still get an authorization error, try logging out, grabbing a cup of tea, and logging back in. It worked for me!

Now that our setup is ready, let's follow the steps to deploy the Bank Management app we built.


Create SAP BAS Project

First, open the SAP BAS application from your BTP Cockpit.

SAP BAS

You'll be redirected to SAP Build since SAP BAS is now a part of it. Click on Create to start a new project.

SAP Build Create Project

Choose Application and click Next.

Create Application in Build

Select Frontend as the category and click Next.

SAP Build App Category

Choose the type SAP Fiori Application, give your project a name, and the Dev Space name will be auto-populated. Click on Review & finally Create.

SAP Build App Type

It might take a few minutes to create the Dev Space.

A dev space is a pre-configured development environment with the tools and extensions needed for a specific scenario. In our case, since we chose to create a frontend application, all the required tools and libraries will be pre-installed. You can always install more libraries or extensions later.

Once the project is created, you can navigate to it to open SAP BAS.

Open SAP BAS Project

Welcome to the SAP BAS tool!

Welcome to BAS

We will deploy our application to Cloud Foundry, so we need to log into it through BAS.

In the search bar at the top, type >cf:login to cloud foundary and press Enter.

Log in using the same credentials as your SAP account or through an SSO passcode. If it doesn't work, I recommend resetting your SAP account password.

Login to CF

In the Cloud Foundry Target, keep the default organization and space names and click Apply.

Since we're deploying a pre-built RAP app, we will create a new project using a template. Go to Menu > File > New Project from Template or, in the top search bar, type >Fiori: Open Application Generator and press Enter.

New BAS Project

Choose the SAP Fiori Generator and then List Report Page, Click Next.

List Report Template

Why a List Report? Because all RAP applications use List Report Fiori templates.

In the Data Source and Service Selection section, choose the service binding you created and click Next.

BAS: Data Source Selection

Keep the Entity Selection intact.

BAS: Entity Selection

Now for a very important part. Enter a Module Name and Application Title, and keep track of the Project Folder Path. Most importantly, make sure to enable Add Deployment Configuration and Add SAP Fiori Launchpad Configuration.

BAS: Project Details

In the Deployment Configuration, choose Cloud Foundry as the target and the router module as shown below.

BAS: Deployment Config

In the SAP Fiori Launchpad Configuration, enter a Semantic Object and Action (they can be anything), then click Finish and wait a few seconds.

BAS: Semantic Details

Without the Semantic Object and Action, your app won't be fully integrated with the SAP Fiori Launchpad. The Launchpad uses this information to create a unique link, allowing users to find and launch your app from a tile or through search. Without it, the deployed app exists but is not easily accessible to end-users.

You have successfully created a Fiori project in SAP BAS!

BAS Project Created

In the top search bar, type >Terminal: Create New Terminal to open the terminal. Once it's open, navigate to your project folder and run the command: npm run start

Preview app in BAS

This will preview your app in a new window, validating that everything is configured correctly.

Next, right-click on the mta.yaml file in the file structure and click on Build MTA Project. Once the commands finish executing, you'll see a new folder called mta_archives with an MTAR file inside. This is the file we will use to deploy our app.

Open a new terminal, navigate to your project folder, and run the command: npm run deploy

Deploy BAS app

MTA stands for Multi-Target Application. It's a way to package multiple application modules and resources (like your UI and backend) into a single file. This file, the MTAR, ensures that all parts of your app are deployed together in the correct order, making the deployment process consistent and reliable.

Once the command is executed, your deployment is successful! Head back to your BTP cockpit and check under HTML5 Applications. Our deployed app should now be listed there.

Deployed app reflecting in HTML5 Apps


Assign Deployed App to SAP Build Work Zone

Now it's time to put SAP Build Work Zone into action. Open the app.

Open SAP Build Work Zone

Create a new site.

Create a Site

Once the site is created, you can navigate to it. You won't see any apps yet because we haven't assigned any.

SAP Build Work Zone Site Navigation

Open Channel Manager and refresh the HTML5 Apps. This is necessary for our application to appear and be available for assignment.

HTML5 Apps Refresh

Open Content Manager and click on Content Explorer.

Content Explorer

Select the HTML5 Apps channel, select our app, and click Add.

Add app to Content Explorer

Go back to the Content Manager, create a new Group, enable the assignment of our deployed application, and save the group.

Group assignment to app

Once again, go back to Content Manager, open the Everyone role, edit it, assign our deployed application to the role, and save.

Role assignment to App

Now, open the site and check again.

App visible to Site: Deploy SAP RAP app to SAP BTP

Did we just finish the whole tutorial? How did that happen? We didn't explicitly assign our app to the site.

If you go to the site's settings and check Role Assignments, you'll see that all apps under the Everyone role are automatically visible on our site.

Site picking apps from role

Kudos!


Common Issues and How to Resolve Them

During the deployment process, you might encounter a few common roadblocks. Here are some of the issues I ran into and how I solved them.

  • Authorization Issues: When working on this blog, I did not start with a completely fresh account. I found that some old services and objects caused authorization problems when selecting the OData service.
    Resolution: Using the booster for SAP Build Apps was the most effective solution, as it automatically created and configured any missing or leftover objects. Starting with a clean environment is always recommended.

  • Incorrect Subscription: Make sure you are subscribed to SAP Build Apps, not SAP Build Code. Choosing the wrong service means the Custom Identity Service will not be subscribed, which can lead to various issues within BAS.

  • Role Assignment: Certain roles are not assigned automatically and must be added manually to your user. Please follow the steps in the blog carefully to ensure you have all the necessary permissions.

  • Finding BAS in SAP Build: The merger of SAP Business Application Studio (BAS) into SAP Build can make it difficult to find the BAS environment directly. Our workaround: We create a simple, dummy project in SAP Build to reach the BAS environment.

  • App Not Appearing in SAP Build Work Zone: If your deployed app isn't showing up on your site, it's likely a matter of step order. It took me a while to realize this, but following the steps in the correct sequence as outlined in the blog will prevent this issue.

Thanks for reading!