Skip to Content
Technical Articles
Author's profile photo Martin Frick

Multitenant SaaS applications on SAP BTP using CAP – The Reloaded Version!

Important Links


SAP BTP, Kyma Runtime scenario

SAP BTP, Cloud Foundry Runtime scenario

Dear community,

This goes out to all the fans of the fabulous CAP framework and all of you being interested in building multitenant Software as a Service (SaaS) solutions on the SAP Business Technology Platform (BTP)!

We are overly excited to bring you some excellent news that is freshly baked and ready to be shared. For readers who’ve followed our blog posts on building SaaS applications within SAP BTP, Kyma, and Cloud Foundry, we’ve got an announcement that will capture your attention.

We are pleased to announce the “reloaded” release of our latest SAP-samples contributions, which harmoniously merges both code lines and documentation from these two environments.

This aligns seamlessly with our goal of providing all of our SAP BTP service offerings, along with our sample applications, agnostic to a specific runtime (neglecting ABAP environment for now). Our aim is to empower our partners and customers with the freedom to choose the runtime that perfectly aligns with their preferences and needs. To explore further, simply follow this link to our new SAP-samples GitHub repository.

Develop a multitenant Software as a Service application in SAP BTP using CAP

If you’re new to the concept of multitenant SaaS applications on SAP BTP, we invite you to explore our previously published blog posts. These posts offer valuable insights that will provide you with a solid understanding of the subject matter at hand.

Multitenant SaaS basics and Cloud Foundry scenario

Advanced multitenant SaaS in a Kyma Scenario

Comparing the Cloud Foundry and Kyma runtime

If you are already acquainted with our previous releases, you can continue reading this blog post to delve into the details of our newly merged repository and its implications for you. As mentioned, what sets this repository apart is its runtime agnosticism. In practical terms, this signifies that deploying the Sustainable SaaS sample solution becomes a seamless endeavour.

Whether your preference leans towards a Kyma Cluster or a Cloud Foundry Landscape, you can achieve this with a single, unified repository. Furthermore, our sample application is crafted on the foundation of the latest CAP release, providing you access to the latest and greatest features.

Great news ahead – since the availability of the SAP Cloud Identity Services like SAP Identity Authentication Service in Trial Environments, even the Advanced Features of ours samples scenario can now be deployed to all available SAP BTP account types. So why not giving it a try in your own account using the latest free tier or trial service plans?

Moreover, we have taken a thoughtful approach to handle runtime-specific code where it is necessary (e.g., handling Cloud Foundry Routes or Kyma API Rules). This is accomplished through the utilization of distinct classes that extend from a shared base class when needed. This architecture ensures a streamlined experience, offering you the flexibility to tailor our project to the unique requirements of each environment. You can find a sample of the mentioned approach as part of our Subscriber Onboarding automation logic (click here).

// Shared logic
class TenantAutomator

// Runtime-specific extensions and overwrites
class CloudFoundry extends TenantAutomator
class Kyma extends TenantAutomator

// Module returns runtime-specific class
// VCAP_APPLICATION only available in Cloud Foundry
export default (process.env.VCAP_APPLICATION ? CloudFoundry : Kyma)

In addition, we have streamlined our branch structure by consolidating it into a singular main branch (compared to three branches in our former Cloud Foundry repository). This modification simplifies the navigation and access to our codebase. Within this code, you will find intelligent checks that determine the availability of service bindings necessary for advanced features.

Consequently, certain code snippets related to Advanced Version features, are executed selectively based on this determination. So, in short, the new repository has code for both the Basic and Advanced Version setup. But which code runs depends on how you’ve set up your services and deployed the sample application to your target runtime.

class UserManagement {
  constructor(token) {
    this.ias = this.#checkIASBinding();
  // Public method creating a new SaaS application user
  async createUser(userInfo) {
    try {
      // SAP IAS user only created if SAP IAS service binding exists
      if (this.ias) {
        user.iasLocation = await this.createIASUser(userInfo)
  // Private method checking for the SAP IAS service binding
  #checkIASBinding() {
    try {
      return xsenv.getServices({ ias:{ label: 'identity' } }) && true;
    } catch (error) {
      return false

In addition to combining the code, there are more improvements in this new repository, especially when it comes to our detailed documentation and step-by-step tutorials:

  • Comprehensive overhaul of documentation
  • Optimization of deployment procedures
  • Streamlined approaches to local and hybrid testing
  • Introduction of exclusive new expert features

Take a look at the new header section of the different documentation chapters. This will help you determine if the steps provided are applicable to your runtime. Keep in mind that certain tutorials are tailored specifically for either the Kyma or Cloud Foundry environment.

  • Kyma

  • Cloud Foundry ✅

We invite you to explore this refreshed repository while we are concurrently working on updating our existing blog posts and GitHub repositories to ensure they seamlessly direct you to the most up-to-date content henceforth.

If you have previously engaged with any of our existing repositories, we kindly encourage you to acquaint yourself with this new release. Moving forward, updates and maintenance will be exclusive to the new version. Maintaining multiple closely parallel codebases would be unsustainable over time, so we appreciate your understanding for this decision.

Your insights and feedback are of great value to us. We invite you to share your thoughts and suggestions in the comments. Additionally, you can effortlessly initiate discussions or report issues on GitHub, should you come across any areas where refinement is possible. Your collaboration contributes significantly to our ongoing improvement efforts.

All the best and stay curious!

Alper Dedeoglu & Martin Frick

Assigned Tags

      You must be Logged on to comment or reply to a post.
      Author's profile photo Abdulbasit Gulsen
      Abdulbasit Gulsen

      Thanks to you and Alper Dedeoglu providing this documentation and samples. It helps a lot to us building our multi-tenant application.

      It looks like only the eventing is missing on the big picture. Looking forward to have eventing service on BTP to use with multi-tenancy as event mesh does not support multi-tenancy any more. This is really must have since some scenarios on S/4HANA Cloud are triggering events and currently there are no way to catch these event to use in multi-tenant extension applications.

      Author's profile photo Martin Frick
      Martin Frick
      Blog Post Author

      Hi Abdulbasit Gulsen,

      Thank you for your encouraging feedback! The event topic has sparked extensive discussions, especially given that the Event Mesh default plan no longer supports multitenancy. The positive aspect is that Alper Dedeoglu is at the forefront of this matter. We eagerly anticipate an expansion of our existing use-case once a successor solution becomes universally accessible. While we await further details, we value your patience and understanding.

      All the best


      Author's profile photo Mustafa Bensan
      Mustafa Bensan

      Hi Martin Frick and Alper Dedeoglu,

      Great to see your latest iteration of the multitenant SaaS samples and documentation.  It's certainly a very valuable reference architecture and accelerator.

      What would be a real game changer is MTX support (multitenancy and extensibility) for PostgreSQL.

      Please keep up the excellent contribution.  I look forward to future versions.



      Author's profile photo Martin Frick
      Martin Frick
      Blog Post Author

      Hi Mustafa Bensan,

      We really appreciate your friendly and motivating words! We are also eagerly anticipating a potential MTX support for PostgreSQL in the near or (hopefully) not-so-distant future, thanks to the awesome efforts of our community!

      We are definitely looking forward to it too! In the meantime, we're excited about our SAP HANA Cloud samples – they're a cool way to get started and grow along the way with our free tier and enterprise service plans.

      All the best,


      Author's profile photo Jason Scott
      Jason Scott

      Thankyou for the fantastic sample app and I really like how you’re continuing to make it better so that it doesn’t go stale like a lot of sample apps do….   😉

      One question I have - I think most customers will be using SAP Work Zone or the S4 Fiori Launchpad to serve apps to their business.
      How would these multi-tenant apps work with work zone? Or how can a customer wire it into their S4 launchpad and still have sso, etc and in-place opening of the app for a great UX?
      Do they simply appear as another content provider allowing a customer to easily add the app(s) to a work zone launchpad?

      Author's profile photo Martin Frick
      Martin Frick
      Blog Post Author

      G'day Jason Scott,

      thanks for your friendly feedback from sunny Oz! Unfortunately, it seems that this feature is not part of the SAP Build Work Zone roadmap as of today. Please feel free to join the Customer Influence created for this topic (click here). As of today, we do not have any viable insights, if and when this requirement will be considered.

      Thanks and all the best,