SAP Business Technology Platform (BTP): Complete Guide for Enterprise Development
SAP Business Technology Platform (BTP) is SAP’s comprehensive platform-as-a-service (PaaS) offering that enables businesses to integrate, extend, and build intelligent applications. This guide covers everything you need to understand and leverage SAP BTP for enterprise development.
What is SAP BTP?
SAP BTP is an integrated offering comprised of four technology portfolios: database and data management, analytics, application development, and intelligent technologies. It provides a unified environment for developing, deploying, and managing enterprise applications that integrate with SAP and non-SAP systems.
Core Value Propositions
- Unified Platform: Single platform for all SAP cloud services
- Multi-Cloud Support: Runs on AWS, Azure, GCP, and SAP data centers
- Enterprise Integration: Native connectivity to SAP S/4HANA, SuccessFactors, and other SAP solutions
- Innovation: AI/ML capabilities, IoT, analytics, and automation
- Open Standards: Cloud Foundry, Kubernetes, and open-source technologies
SAP BTP Architecture
High-Level Structure
┌─────────────────────────────────────────────────────────────┐│ SAP BTP Global Account ││ ││ ┌─────────────────┐ ┌─────────────────┐ ││ │ Directory 1 │ │ Directory 2 │ ││ │ │ │ │ ││ │ ┌──────────────┴┐ │ ┌──────────────┴┐ ││ │ │ Subaccount 1 │ │ │ Subaccount 3 │ ││ │ │ (Dev) │ │ │ (Prod) │ ││ │ │ │ │ │ │ ││ │ │ Runtime: │ │ │ Runtime: │ ││ │ │ Cloud Foundry │ │ │ Cloud Foundry │ ││ │ │ │ │ │ + Kyma │ ││ │ │ Services: │ │ │ │ ││ │ │ • HANA Cloud │ │ │ Services: │ ││ │ │ • XSUAA │ │ │ • HANA Cloud │ ││ │ │ • Destination │ │ │ • XSUAA │ ││ │ └───────────────┘ │ │ • Integration │ ││ │ │ │ Suite │ ││ │ ┌──────────────┐ │ └───────────────┘ ││ │ │ Subaccount 2 │ │ ││ │ │ (Test) │ │ ││ │ └──────────────┘ │ ││ └─────────────────┘ └─────────────────┘ │└─────────────────────────────────────────────────────────────┘Key Components
1. Global Account
- Top-level entity for your organization
- Contains entitlements and quotas
- Billing and commercial relationship with SAP
2. Directories (Optional)
- Organize subaccounts hierarchically
- Manage entitlements distribution
- Implement governance structure
3. Subaccounts
- Isolated environments for specific purposes
- Host applications and services
- Map to environments (Dev, Test, Prod) or business units
4. Spaces (Cloud Foundry)
- Logical separation within subaccounts
- Contain applications and service instances
- Map to teams or projects
Runtime Environments
SAP BTP offers multiple runtime environments for different use cases:
1. Cloud Foundry Runtime
Best for: Traditional microservices, APIs, web applications
# manifest.yml - Cloud Foundry application descriptor---applications:- name: my-app memory: 512M instances: 2 buildpacks: - nodejs_buildpack path: ./ routes: - route: my-app-prod.cfapps.eu10.hana.ondemand.com services: - my-hana-db - my-xsuaa - my-destination env: NODE_ENV: production SAP_JWT_TRUST_ACL: '[{"clientid":"*","identityzone":"*"}]'Key Features:
- Auto-scaling and self-healing
- Built-in load balancing
- Service marketplace
- Multi-target applications (MTA)
- Blue-green deployments
2. Kyma Runtime
Best for: Kubernetes-native applications, event-driven architectures
# deployment.yaml - Kyma/Kubernetes deploymentapiVersion: apps/v1kind: Deploymentmetadata: name: my-app namespace: productionspec: replicas: 3 selector: matchLabels: app: my-app template: metadata: labels: app: my-app spec: containers: - name: app image: your-registry/my-app:v1.0.0 ports: - containerPort: 8080 env: - name: HANA_HOST valueFrom: secretKeyRef: name: hana-credentials key: host---apiVersion: v1kind: Servicemetadata: name: my-appspec: selector: app: my-app ports: - port: 80 targetPort: 8080 type: LoadBalancerKey Features:
- Full Kubernetes compatibility
- Istio service mesh
- Serverless functions
- Event mesh integration
- Extension framework for SAP solutions
3. ABAP Runtime
Best for: Extending SAP S/4HANA, ABAP development
- Steampunk (ABAP Cloud)
- RESTful ABAP Programming (RAP)
- Native ABAP on cloud
Core Services
1. SAP HANA Cloud
Enterprise-grade database and data warehouse:
-- CDS (Core Data Services) View@AbapCatalog.sqlViewName: 'ZSALESORDER'@AbapCatalog.compiler.compareFilter: true@AbapCatalog.preserveKey: true@AccessControl.authorizationCheck: #CHECK@EndUserText.label: 'Sales Order View'
define view Z_SALES_ORDER_VIEW as select from snwd_so association [1..1] to snwd_bpa as _BusinessPartner on $projection.buyer_guid = _BusinessPartner.node_key{ key node_key as OrderId, so_id as OrderNumber, buyer_guid as BuyerId, currency_code as Currency, gross_amount as GrossAmount, net_amount as NetAmount, _BusinessPartner.bp_id as CustomerNumber, _BusinessPartner.company_name as CustomerName}Capabilities:
- In-memory computing
- Multi-model (relational, graph, spatial, JSON)
- Data lake integration
- Advanced analytics
- Real-time replication
2. Connectivity & Destinations
Connect to on-premise and cloud systems:
const xsenv = require('@sap/xsenv');const { retrieveJwt } = require('@sap-cloud-sdk/connectivity');
async function getDestination(destinationName) { const { destination } = require('@sap-cloud-sdk/connectivity');
return destination.fetchDestination({ destinationName: destinationName, jwt: retrieveJwt(req) });}
async function callBackendSystem(req, res) { try { const dest = await getDestination('MY_BACKEND_SYSTEM');
const response = await axios.get('/api/data', { baseURL: dest.url, headers: { ...dest.headers, 'Authorization': dest.authentication }, httpsAgent: dest.certificates ? new https.Agent({ ca: dest.certificates }) : undefined });
res.json(response.data); } catch (error) { console.error('Error calling backend:', error); res.status(500).json({ error: 'Backend call failed' }); }}3. XSUAA (Authorization and Trust Management)
OAuth 2.0-based authentication and authorization:
{ "xsappname": "my-app", "tenant-mode": "dedicated", "scopes": [ { "name": "$XSAPPNAME.Read", "description": "Read access" }, { "name": "$XSAPPNAME.Write", "description": "Write access" } ], "role-templates": [ { "name": "Viewer", "description": "View-only access", "scope-references": [ "$XSAPPNAME.Read" ] }, { "name": "Editor", "description": "Full access", "scope-references": [ "$XSAPPNAME.Read", "$XSAPPNAME.Write" ] } ], "role-collections": [ { "name": "MyApp_Viewer", "description": "MyApp Viewer Role", "role-template-references": [ "$XSAPPNAME.Viewer" ] } ]}// Middleware to check authorizationconst xssec = require('@sap/xssec');const passport = require('passport');
passport.use(new xssec.JWTStrategy(xsenv.getServices({ uaa: { tag: 'xsuaa' }}).uaa));
app.use(passport.initialize());app.use(passport.authenticate('JWT', { session: false }));
// Check scope in routeapp.get('/api/sensitive-data', checkScope('Write'), (req, res) => { // Only accessible with Write scope res.json({ data: 'sensitive' }); });
function checkScope(scope) { return (req, res, next) => { if (req.authInfo.checkScope(`$XSAPPNAME.${scope}`)) { next(); } else { res.status(403).json({ error: 'Insufficient permissions' }); } };}4. SAP Business Application Studio
Cloud-based IDE optimized for SAP development:
Features:
- Pre-configured dev spaces for different scenarios
- SAP Fiori tools integration
- CAP development tools
- Git integration
- Debugging and testing
Multi-Target Applications (MTA)
MTA enables deploying complex applications with multiple modules:
_schema-version: '3.3'ID: my-business-appversion: 1.0.0description: "Multi-target application for business processes"
modules: # Node.js backend (CAP) - name: my-app-srv type: nodejs path: gen/srv requires: - name: my-app-db - name: my-app-uaa - name: my-app-destination provides: - name: srv-api properties: srv-url: ${default-url}
# Database deployment - name: my-app-db-deployer type: hdb path: gen/db requires: - name: my-app-db
# UI deployer - name: my-app-ui type: html5 path: app/webapp build-parameters: builder: custom commands: - npm run build supported-platforms: [] requires: - name: srv-api group: destinations properties: forwardAuthToken: true strictSSL: true name: srv-api url: ~{srv-url}
resources: # HANA Cloud - name: my-app-db type: com.sap.xs.hdi-container parameters: service: hana service-plan: hdi-shared
# XSUAA - name: my-app-uaa type: org.cloudfoundry.managed-service parameters: service: xsuaa service-plan: application path: ./xs-security.json
# Destination - name: my-app-destination type: org.cloudfoundry.managed-service parameters: service: destination service-plan: lite
# HTML5 Application Repository - name: my-app-html5-repo type: org.cloudfoundry.managed-service parameters: service: html5-apps-repo service-plan: app-hostDeploy with:
# Build MTA archivembt build
# Deploy to Cloud Foundrycf deploy mta_archives/my-business-app_1.0.0.mtarIntegration Scenarios
1. Extending S/4HANA with Side-by-Side Extensions
// Extension application calling S/4HANA OData serviceconst cds = require('@sap/cds');
module.exports = async function() { const { BusinessPartner } = this.entities; const s4hana = await cds.connect.to('S4HANA');
// Before creating local entity, check S/4HANA this.before('CREATE', 'Customer', async (req) => { const bpNumber = req.data.businessPartnerNumber;
// Call S/4HANA const bp = await s4hana.run( SELECT.one.from('A_BusinessPartner') .where({ BusinessPartner: bpNumber }) );
if (!bp) { req.error(404, `Business Partner ${bpNumber} not found in S/4HANA`); }
// Enrich with S/4HANA data req.data.businessPartnerName = bp.BusinessPartnerName; req.data.country = bp.Country; });
// Expose combined data this.on('READ', 'Customer', async (req, next) => { const customers = await next();
// Enhance with real-time S/4HANA data for (let customer of customers) { const creditInfo = await s4hana.run( SELECT.one.from('A_CustomerCreditInfo') .where({ Customer: customer.businessPartnerNumber }) ); customer.creditLimit = creditInfo?.CreditLimit; customer.creditExposure = creditInfo?.CreditExposure; }
return customers; });};2. Event-Driven Architecture with SAP Event Mesh
// producer.js - Publishing eventsconst { EventEmitter } = require('@sap/xb-msg-env');
async function publishOrderCreated(order) { const messaging = await EventEmitter.connect();
await messaging.send('orderCreated', { source: 'order-service', type: 'sap.s4.beh.salesorder.v1.SalesOrder.Created.v1', data: { salesOrder: order.orderNumber, customer: order.customerId, amount: order.totalAmount, currency: order.currency } });
console.log(`Published order created event: ${order.orderNumber}`);}
// consumer.js - Consuming eventsconst { MessageConsumer } = require('@sap/xb-msg-env');
async function subscribeToOrderEvents() { const messaging = await MessageConsumer.connect();
messaging.on('orderCreated', async (message) => { console.log('Received order created event:', message.data);
// Process event await processNewOrder(message.data);
// Acknowledge message.ack(); });
messaging.on('error', (error) => { console.error('Messaging error:', error); });}Best Practices
1. Account Structure
Global Account (Enterprise)├── Directory: Production│ └── Subaccount: PROD-EU│ ├── Space: api-services│ ├── Space: web-apps│ └── Space: background-jobs├── Directory: Non-Production│ ├── Subaccount: DEV│ │ └── Space: development│ ├── Subaccount: TEST│ │ └── Space: testing│ └── Subaccount: QA│ └── Space: quality-assurance└── Directory: Sandbox └── Subaccount: SANDBOX └── Space: experiments2. Service Management
- Use service instances per environment
- Implement proper key rotation
- Monitor service usage and quotas
- Use service plans appropriate for workload
3. Security
// Implement proper authentication checksapp.use((req, res, next) => { // Verify JWT token if (!req.authInfo || !req.authInfo.checkLocalScope('Read')) { return res.status(403).json({ error: 'Forbidden', message: 'Insufficient permissions' }); } next();});
// Implement audit loggingconst auditLog = require('@sap/audit-logging');const credentials = xsenv.getServices({ auditlog: { tag: 'audit-log' } }).auditlog;
auditLog.v2(credentials, (err, auditLogClient) => { if (err) { console.error('Failed to initialize audit log:', err); return; }
// Log data access auditLogClient.read({ user: req.user.id, object: { type: 'Customer', id: customerId }, data: { before: oldData } }).log((err) => { if (err) console.error('Audit log failed:', err); });});4. Performance Optimization
- Use caching strategically
- Implement connection pooling
- Optimize database queries
- Use async/await properly
- Implement proper error handling
5. Monitoring and Observability
// Custom metrics with Application Loggingconst logging = require('@sap/logging');const appContext = logging.createAppContext();
const logger = appContext.createLogContext().getLogger('/Application');
// Structured logginglogger.info('Order processed', { orderId: order.id, amount: order.amount, processingTime: Date.now() - startTime});
// Error trackinglogger.error('Payment failed', { orderId: order.id, error: error.message, stack: error.stack});Development Workflow
1. Local Development
# Initialize CAP projectcds init my-project --add samples
# Install dependenciesnpm install
# Run locally with mock datacds watch
# Deploy to local SQLitecds deploy --to sqlite2. Build and Deploy
# Build MTAmbt build -t gen --mtar my-app.mtar
# Login to Cloud Foundrycf login -a https://api.cf.eu10.hana.ondemand.com
# Target org and spacecf target -o myorg -s dev
# Deploycf deploy gen/my-app.mtar
# Check statuscf appscf services3. CI/CD Pipeline
stages: - build - test - deploy
build: stage: build image: node:18 script: - npm install - npm run build - mbt build artifacts: paths: - mta_archives/
test: stage: test image: node:18 script: - npm install - npm test - npm run test:integration
deploy-dev: stage: deploy image: cloudfoundry/cf-cli script: - cf login -a $CF_API -u $CF_USER -p $CF_PASSWORD -o $CF_ORG -s dev - cf deploy mta_archives/*.mtar only: - develop
deploy-prod: stage: deploy image: cloudfoundry/cf-cli script: - cf login -a $CF_API -u $CF_USER -p $CF_PASSWORD -o $CF_ORG -s prod - cf deploy mta_archives/*.mtar --strategy blue-green only: - main when: manualCost Optimization
Entitlement Management
- Monitor usage in SAP BTP Cockpit
- Right-size service plans
- Use free tier for development
- Implement auto-scaling
- Delete unused service instances
Service Plan Selection
| Service | Dev/Test | Production |
|---|---|---|
| HANA Cloud | hdi-shared | hana (dedicated) |
| XSUAA | application | application |
| Destination | lite | lite/standard |
| Connectivity | lite | connectivity_proxy |
Conclusion
SAP Business Technology Platform provides a comprehensive, enterprise-grade platform for building, integrating, and extending business applications. With support for multiple runtimes, deep SAP integration capabilities, and a rich service ecosystem, SAP BTP enables organizations to innovate while leveraging their existing SAP investments.
Success with SAP BTP requires understanding both the platform capabilities and SAP’s unique approach to enterprise development. Start with small extensions, master the core services, and gradually build more complex solutions.
Ready to master SAP BTP? Our SAP BTP training programs cover everything from fundamentals to advanced integration patterns with hands-on labs. Contact us for customized training tailored to your team’s needs.