Development of Custom Web Applications Within SAP Business Technology Platform
SAP Business Technology Platform (SAP BTP) is a cloud-based platform designed to empower businesses in refining, integrating, and expanding their applications.
Join the DZone community and get the full member experience.
Join For FreeThis all-encompassing platform equips organizations with the agility, flexibility, and scalability needed to execute their business operations seamlessly in the cloud. Its extensive services include database management, integration, application development, analytics, and more.
SAP BTP offers support for both vertical and horizontal scaling, enabling enterprises to effectively manage heightened workloads as they expand. Vertical scaling entails augmenting the capacity of existing infrastructure resources, while horizontal scaling necessitates the addition of identical instances, followed by load distribution optimization.
Further augmenting its offerings, SAP BTP encompasses an array of services, including SaaS (Software as a Service) and PaaS (Platform as a Service). This diversity enables organizations to harness the potential of cloud computing technology, propelling them toward the realization of their business objectives.
A Bit of Theory
Firstly introduced in 2013 under the name of HANA Cloud Platform, SAP BTP became one of the popular tools for developing SAP extensions and dedicated business applications. Nowadays, this platform supports three main development environments — Cloud Foundry, Kyma, and ABAP Environment (Steampunk).
Kyma (a fully managed cloud-native Kubernetes application runtime) is not widely used but looks flexible and promising. Cloud Foundry, however, earned a lot of popularity as a main runtime for development of custom applications and extensions within BTP.
Cloud Foundry functions as a Platform as a Service (PaaS), furnishing developers with an assortment of tools and services to facilitate the creation, deployment, and management of applications within a cloud-based infrastructure. It offers compatibility with multiple programming languages and technologies, including the following:
- Node.js
- Java
- Python
- .NET
It encompasses an array of developer utilities like:
- Cloud Foundry Command Line Interface (CLI)
- Cloud Foundry API
In addition, Cloud Foundry extends its support to a rich set of reusable services, like Advanced Event Mesh, Document Management, Object Store, Feature flags, HTML5 Repository, Application Autoscaler, Redis, Postgres, embedded CI/CD, and many others.
Developing Custom Applications and Extensions With SAP BTP
Cloud Foundry and Kyma runtime ushers in a realm where crafting personalized applications is seamlessly attainable, leveraging a spectrum of favored runtimes — be it Java, Node.js, Python, and more — alongside beloved frameworks like Nest.js, Express.js or SAP CAP (Cloud Application Programming) tailored for Node.js. Delving deeper, let's explore pivotal facets inherent to this distinctive approach to development.
Note: Within this article, our focus will exclude methodologies associated with extension development through low-code or no-code solutions. Instead, we will exclusively center our attention on a pro-code approach to the implementation of custom applications and extensions.
Question #1: How Can I Implement Authentication in BTP?
By default, authentication is managed by SAP IAS (Identity Authentication Service), one of the services provided by SAP BTP. It encompasses essential features, including customized login page design, user management, MFA administration, authentication federation, and SSO, among others. As IAS stores user identities, the distinct XSUAA (OAuth2 Provider) service generates and validates security tokens, in addition to performing authorization checks based on roles and scopes governed within the BTP cockpit.
Question #2: Where Can I Store Data in BTP?
The prevalent method entails utilizing the SAP HANA Cloud service, which can be procured as a dedicated service. This service provides a shared cloud database with nearly all essential core SAP HANA functionalities.
Question #3: Can I Integrate With Other Systems?
The embedded connectivity and destination services provide methods for establishing connections to both on-premise and cloud environments. Given that Cloud Foundry and Kyma operate within a public cloud framework, all Internet-based resources can be naturally accessed through configured destinations, offering various authentication choices.
In the context of on-premise connectivity, SAP offers the SAP Cloud Connector as part of its connectivity service. This utility can be installed within on-premise landscapes to expose data to your BTP application through a secure tunnel.
What the Development Process Will Look Like
Preparation
Basic operations within the SAP BTP Cloud Foundry landscape can be executed using the CLI tool. While these operations are ideally automated through CI/CD tools in actual projects, during local development, a handful of commands usually need to be run via the Cloud Foundry CLI. The fundamental set of commands includes the following:
cf api ...
— to establish a connection with the specific sub-account.cf login
— to log in to the CF sub-account.
Following this, you'll be prompted to choose the organization (org) name and space before any further actions can be executed.
Creating the Service Instance (Node.js)
Each application within the Cloud Foundry landscape begins with an app descriptor — a distinct set of instructions essential for the correct deployment of the application. The fundamental app descriptor, typically found in the project folder's root directory and named manifest.yml, can take a form similar to the following example for a Node.js app:
applications:
- name: service_backend
random-route: true
path: service_backend
memory: 256M
buildpacks:
- nodejs_buildpack
Once this step is completed, proceed to the "service_backend" project folder and generate a standard Node.js project using your preferred framework. Remember to define the default URL handler and include a "start" script within the package.json file, ensuring the proper launch of your application.
By employing the cf push
CF CLI command, you can successfully deploy your application to the Cloud Foundry landscape. The corresponding application URL will become accessible when the deployment process is complete.
Creating the UI
Creation of the UI in SAP BTP Cloud Foundry can follow the standard approaches available on the internet. In order to deploy and run static UI applications in BTP, you are required to create and maintain several services responsible for content storage and deployment.
Within the Cloud Foundry runtime, UI applications are served as static content as part of the application itself or from the designated HTML5 Application Repository in order to manage its lifecycle. The simplest approach might be to upload static content to the SAP BTP via so-called staticfile_buildpack. Let's explore the app descriptor for our fundamental HTML5 application (in a very simple scenario, static resources are uploaded as part of the application):
applications:
- name: service_frontend
random-route: true
path: service_frontend
memory: 128M
buildpacks:
- staticfile_buildpack
path: ./dist
As you can see in the example, - static_file buildpack
will be responsible for storing the content, which will be retrieved from the /dist
folder. That means that the UI project needs to be compiled into a set of consumable HTML/JS/CSS resources using industry-standard tools like Vite or Webpack. It's crucial to note that Cloud Foundry does not undertake application builds. Therefore, if you are using technologies like React, it's imperative to gather your built application resources within the service_frontend
folder prior to executing the cf push
command. This process aligns with the example illustrated in our sample app descriptor file.
Note: While it is possible to generate a new app descriptor for each individual app or divide modules in the most suitable manner, it is also possible to adopt a unified app descriptor for the entire project. This approach is called "Multitarget application" — an approach that amalgamates various components developed using distinct technologies into a single application with a shared lifecycle.
Routing
To effectively handle application incoming requests (and later — authentication), we must introduce another concept known as the App Router. The App Router is an SAP Node.js module that functions as a proxy for frontend applications, directing their requests to relevant destinations. Since the app router is a Node.js module, it should be defined within the app descriptor as follows:
applications:
- name: service_approuter
properties:
SEND_XFRAMEOPTIONS: false
memory: 128M
buildpacks:
- nodejs-buildpack
Within the Cloud Foundry environment of SAP BTP, you have the capability to execute an application that has been uploaded to an HTML5 application repository via the central Managed Application Router (SaaS Approuter). This service not only enables the serving of static content from an HTML5 application repository but also facilitates user authentication, URL rewriting, and the forwarding or proxying of requests to other microservices, all while ensuring the propagation of user information.
Since the app router will be the central place in the service landscape, which will be responsible for request handling — it is mandatory to secure it with additional parameters. All routes supported by the application are managed by the JSON-based configurations which will then later tell your App Router how to handle incoming requests.
{
"source": "^/service-api/(.*)$",
"target": "/service-api/$1",
"destination": "service_backend",
"authenticationType": "xsuaa"
},
Let’s talk about what this authenticationType: xsuaa
parameter actually does.
Integration With Identity Provider
At this juncture, the application we have can be accessed but lacks support for any authentication mechanisms. Consequently, anyone can access the endpoints without requiring authentication.
XSUAA service generates unique auth tokens, assigning them to user sessions, checking them, and verifying user identity through the trusted identity provider. Thus, the XSUAA service has to be on the list of dependencies for our services, specifically the back-end and application router, respectively. In “services,” we need to specify a new dependency as follows:
services: - services-xsuaa
Note: The XSUAA service does not manage users' data or user records on its own. The XSUAA service needs a trusted connection to a designated Identity Provider. This can be the SAP ID Service or another corporate user store that was integrated into the SAP BTP. The integration can be made via "SAP Cloud Identity Services — Identity Authentication Service (IAS).”
By default, user management within SAP BTP is done through the Cockpit and using the default SAP ID Service (accounts.sap.com) as an Identity Provider. However, in practice, this approach is rarely employed in production applications due to its limited user management capabilities.
Database Setup
The most commonly embraced standard for storing structured business data in SAP BTP is SAP HANA Cloud database. There is a standard, well-documented way to connect to it via “@sap/hana-client” — SAP HANA Node.js Driver. After you’ve established the connection via library SDK, you can execute SQL statements or even make use of ORM like TypeORM, which also supports HANA databases.
Integration With a Third-Party Source
When it is required to connect third-party data sources (like RESTful API), the best option will be to create a new destination via Destination Service in BTP. This service lets you find the destination information that is required to access a remote service or system from your Cloud Foundry application as follows:
- To connect to an on-premise system, you can optionally use this service along with (i.e., in addition to) the Connectivity service, which provides secure access to isolated networks through Cloud Connector.
- To connect to any other Web application (remote service), you can use the Destination service without the Connectivity service.
Destination Service supports several protocols and authentication mechanisms, including Basic, Certificate, OAuth2/OpenID, SAML, etc.
Scenarios It Supports
Side-By-Side Extensions for S/4HANA
Applying the "keep the core clean" principle when implementing S/4HANA through the SAP Business Technology Platform (SAP BTP) is crucial for maintaining a robust and agile system. By adhering to this approach, you ensure that your S/4HANA core remains untouched by unnecessary modifications, preserving its stability and simplifying future upgrades.
SAP BTP provides a versatile environment to extend S/4HANA's functionalities without compromising its integrity. Leveraging capabilities such as side-by-side extensions, APIs, and microservices, you can seamlessly enhance and customize your S/4HANA landscape while isolating changes from the core system.
This approach enables you to develop innovative solutions, create custom applications, and integrate with external services — all within the SAP BTP environment. By keeping the core clean, you establish a foundation for agility, adaptability, and sustainable growth, ensuring that your S/4HANA implementation remains efficient, resilient, and aligned with your evolving business needs.
Extensions of the Other SAP Cloud ERP Solutions
Extending SAP Cloud ERP solutions (SAP Ariba, SAP SuccessFactors, SAP C4C, etc.) through the SAP Business Technology Platform (SAP BTP) introduces a realm of possibilities for enhancing and tailoring your ERP environment to meet specific business requirements. By leveraging SAP BTP's diverse tools and services, you can seamlessly create, integrate, and manage extensions that complement your SAP ERP setup.
In essence, extending SAP Cloud solutions using SAP BTP empowers your organization to tailor its ERP environment to its unique needs, foster innovation, and optimize business processes while keeping the core ERP system intact and stable.
Custom Web and Mobile Application Development
SAP BTP provides a robust set of tools, services, and resources that streamline the development process and enable you to create applications that align seamlessly with your organization's objectives. Its extensive capabilities provide the foundation for creating innovative, scalable, secure, and user-centric applications that enhance your organization's efficiency and productivity.
Opinions expressed by DZone contributors are their own.
Comments