Technology Blogs by SAP
Learn how to extend and personalize SAP applications. Follow the SAP technology blog for insights into SAP BTP, ABAP, SAP Analytics Cloud, SAP HANA, and more.
cancel
Showing results for 
Search instead for 
Did you mean: 
akansha_tiwari
Advisor
Advisor
Transitioning to the cloud and developing multitenant applications is a key requirement that nearly every customer has these days. When working with SAP Business Application Studio using productivity tools it is possible for you to achieve this goal with minimum efforts.

To dive deeper, let’s start by understanding multitenancy and its benefits.

What is Multitenancy?

With multitenant architecture a single instance of an application serves multiple consumers. Application providers can own, deploy, and operate tenant-aware applications for multiple consumers. Consumers share resources, so they are used more effectively with reduced costs. The application consumers can launch the applications using consumer-specific URLs and can configure certain application features. SAP Business Technology Platform provides such a multitenant functionality.

There are 3 key terms with respect to multitenancy:

  • Provider Account: This is a sub-account in an SAP Business Technology Platform Global account on which the application is deployed.

  • Consumer/Subscriber Account: This can be a sub-account in an SAP Business Technology Platform’s Global account (owned by customer or SAP) in which the application is subscribed for the customer. This sub-account is owned by the customer.

  • Tenant aware service – This is a service (SaaS) that separates the data of each tenant or subscriber.


With multitenant applications, you can:

  • Isolate data securely for each tenant

  • Optimize resources by sharing them among tenants.

  • Update applications for all tenants in one step instead of approaching it one by one.



Multitenancy


Steps to develop and deploy a multitenant application in Cloud Foundry are:

  1. Create a multitenant CAP application in SAP BTP.

  2. Deploy the Multitenant application to provider subaccount in Cloud Foundry.

  3. Configure the approuter application.

  4. Bind the multitenant application and approuter to xsuaa service instance.

  5. Register application to SAP SaaS Provisioning service.

  6. Application is available to consumers for subscription.


 

How can you achieve this using SAP Business Application Studio Productivity tools:



  1. Create a CAP application, using SAP Business Application Studio and Enable SaaS multi-tenancy in Guide center.

  2. Deploy the Multitenant application to provider subaccount in Cloud Foundry.

  3. Application is available to consumers for subscription.


SAP Business Application Studio (Productivity Toolkit) provides a Collection of low code tools enabling developers to easily build full stack applications for desktop and mobile use.

Step1


Create a new project in SAP Business Application Studio using the Productivity Toolkit


Create Project


Create the Cloud Application Programming data model, Service and UI:


Create Data Model


Service


Create Service


UI Application


Create UI Application


You can also refer to this tutorial to create a simple application in SAP Business Application Studio.

After creating the application, go to the Guide Center from the left panel.


Open Guide Center


You will find a Guide "Enable SaaS in your Application”.


Enable Multitenancy


You will get a confirmation popup, select "Enable SaaS".


Multi-tenancy will be enabled for your project.

Note: Once SaaS is enabled for your application, it cannot be reversed.


Multitenancy Enabled


Now, you can see that your project is marked as a SaaS project in the project explorer.


SaaS enabled Project


To view the multitenancy code, click on the explorer on the left-hand side panel and go to “package.json”. You will see that by using SAP Business Application Studio to enable Multitenancy, following has been automated:

  • Added package @Sap/cds-mtxs to your project





  • Added these lines to your project's json to enable multitenancy with sidecar





  • Added a sidecar subproject at mtx/sidecar with this json





  • Modified deployment descriptors such as mta.yaml for Cloud Foundry




Step 2


As a next step, deploy your application to Cloud Foundry. You can do so by clicking the three dots besides project name.

Note: SAP HANA Cloud instance must exist already in your SAP BTP subaccount where you are deploying this application


Deploy project to Cloud Foundry



Go to the dev space of your subaccount in SAP Business Technology Platform (SAP BTP) cockpit and you will find the following applications:


Applications


Go to Services-->Instances and search for you application name with suffix “-destination”.


Select this instance and click on “Manage Instance”


Next, go to “Destinations” and click on edit:


Add user and password who has access to the provider account and clear the “Client Secret”. Save the destination.


Save the destination.

Step 3


Your service is now available on SAP BTP Cockpit service marketplace to be subscribed. Go ahead and subscribe to the application.

Please note that this application can be subscribed from subaccounts within the same Global account only.


Subscribe from Marketplace


Launch the application to check using the icon next to application name.



Summary

By following this blog, you have gained an insight on usage of Productivity tools in SAP Business Application Studio to develop and deploy a multitenant application in SAP BTP Cloud Foundry. Do try this feature in SAP Business Application Studio and let us know your feedback.
8 Comments
Aryan_Raj_Sinha
Advisor
Advisor
0 Kudos
Hi Akansha! Great blog! I went through the steps and deployed my app successfully, however, when I try to subscribe to it, I get the following error:


Couldn't subscribe to susaasstory. Please try again. If the problem persists, open a ticket using the BCP component for this application.


Technical Details:
subscribe failed. Error: subscribe failed in create callback. Error description: CorrelationId: 0c4866d6-268c-4660-6946-570b37148bba, Details: Error manage callbacks: Failed to call callback url PUT: https://technical-field-enablement-devops-1-am6jb1u8-dev-susaas6065aa67.cfapps.us20.hana.ondemand.co..., correlationId: 0c4866d6-268c-4660-6946-570b37148bba, appName: susaasstory and consumer tenant: 5bd82242-77cd-4d14-a00c-ea6ef1530ddb. Body: SubscriptionCallbackPayloadDto(subscriptionAppName=susaasstory, subscriptionCommercialAppName=susaasstory, subscriptionAppId=susaasstory!t6381, subscribedTenantId=5bd82242-77cd-4d14-a00c-ea6ef1530ddb, subscribedSubaccountId=5bd82242-77cd-4d14-a00c-ea6ef1530ddb, providerSubaccountId=a7f270c5-cd6e-4c50-9a2f-c94a906c578f, subscriptionGUID=6b8e071d-492d-45a8-b2cc-43d0eed74f81, subscribedZoneId=5bd82242-77cd-4d14-a00c-ea6ef1530ddb, subscribedSubdomain=devops-2-wt4riori, subscribedLicenseType=DEVELOPER, subscribedCrmId=null, subscriptionAppPlan=null, subscriptionAppAmount=null, subscriptionMovedFromSaasProvisioning=null, subscriptionAppNameBeforeMovedFromSaas=null, dependantServiceInstanceAppIds=null, userId=aryan.raj.sinha@sap.com, subscriptionParams=null, userInfo=UserInfoPojo(userId=aryan.raj.sinha@sap.com, userGuid=0e80d828-be9f-4fd9-9c5d-1f796df0cf44, userName=aryan.raj.sinha@sap.com, email=aryan.raj.sinha@sap.com, subIdp=I586826, sub=0e80d828-be9f-4fd9-9c5d-1f796df0cf44), appProviderCustomProperties=null, dependentServiceInstancesInfo=null, dependentServiceInstanceAppIds=null, additionalInformation={tenantMetadataUrl=https://devops-2-wt4riori.authentication.us20.hana.ondemand.com/saml/metadata}, globalAccountGUID=4c28a87c-ca19-45be-b884-ec6a6b3a1226, eventType=CREATE) Reason: returned value from application: 500 INTERNAL_SERVER_ERROR, with body: {"error":{"code":"500","message":"Internal Server Error"}}


Can you help with this?


akansha_tiwari
Advisor
Advisor
0 Kudos
Hi Aryan,

As I understand some steps were manually performed in your use case, so please use the "Deploy" button in project explorer as specified. There are some steps automated with this feature and will work with the steps provided in the blog. I hope this helps.

 

Regards

Akansha
Aryan_Raj_Sinha
Advisor
Advisor
0 Kudos
Hi Akansha,

I tried the exact same steps without any manual deployment for my Trial account. The deployment worked but I am unable to subscribe to the service from my subaccount.

Regards,

Aryan
akansha_tiwari
Advisor
Advisor
0 Kudos
Hi Aryan,

Please perform the destination modification as updated in step 2 in the blog. This should resolve the issue.

Regards

Akansha
Aryan_Raj_Sinha
Advisor
Advisor
0 Kudos

Hi Akansha,

Thanks for the clarification. I was able to make the saas app work.

Regards,

Aryan

shalabh_jain
Employee
Employee
Very nice and relevant blogpost. Thanks for sharing!
harianantha
Participant
0 Kudos

Hi akansha.tiwari ,

Really great blog. Thanks for sharing !!

I've followed the steps and subscribed from the Provider Sub account itself, but when I launch the app nothing is happening and getting Site can't be reached error. Please see the below image. Thank you!!


And when I try to execute app from the "CF->Space->Applications" as shown below..


It's opening below authentication screen. I've tried with both my btp credentials & xsuaa client id and secret but it's not working.



Could you please help me out ? Thank you !!

akansha_tiwari
Advisor
Advisor
0 Kudos

Hi Harianantha,

Please create a subscription sub-account and subscribe to the application and then launch it. 

Thanks!

Akansha