界面已本地化;技能介绍与说明文档按所选语言由 AI 自动翻译,代码、命令、路径和专业术语保留原文,以原作者文档为准。
探索技能
数据与研究 · SKILL.md

sap-btp

sap-btp

【数据与研究】This skill handles SAP BTP (Business Technology Platform) development including CAP (Cloud Application Programming Model), Fiori Elements, SAP Build Apps, Integration Suite, side-by-side extensions, OData V2/V4 services, event-driven architecture, and BTP security. Use when user mentions BTP, CAP, CAPM, Fiori, Fiori Elements, OData, Integration Suite…

独立 GitHub 快照 · 自动分类 · 以原作者文档为准

技能说明

GitHub

name: sap-btp description: > This skill handles SAP BTP (Business Technology Platform) development including CAP (Cloud Application Programming Model), Fiori Elements, SAP Build Apps, Integration Suite, side-by-side extensions, OData V2/V4 services, event-driven architecture, and BTP security. Use when user mentions BTP, CAP, CAPM, Fiori, Fiori Elements, OData, Integration Suite, iFlow, side-by-side extension, BTP cockpit, subaccount, service binding, XSUAA, destination, Cloud Foundry, Kyma, event mesh, SAP Build, HANA Cloud, BTP ABAP environment, MTA. allowed-tools: Read, Grep

1. BTP Landscape Structure

Global Account
└── Subaccount (region-specific)
    ├── Cloud Foundry (CF) Environment
    │   └── Spaces → CF Applications + Service Instances
    ├── Kyma Environment
    │   └── Namespaces → Pods / Serverless Functions
    └── BTP ABAP Environment
        └── ABAP Instances (Clean Core ABAP development)

Key platform services:

ServicePurpose
XSUAAOAuth 2.0 authorization server — user auth + service-to-service
Destination ServiceConnection config to backend systems (S/4HANA, etc.)
Connectivity ServiceOn-premise access via Cloud Connector (SCC)
Event MeshAsync event-driven messaging between applications
HANA CloudManaged SAP HANA database service
Alert NotificationEvent-based alerting and notification

2. CAP (Cloud Application Programming Model)

Project Structure

my-cap-project/
├── db/
│   └── schema.cds         ← Data model (entities, associations)
├── srv/
│   ├── service.cds        ← Service definition (projection, actions, functions)
│   └── service-impl.js    ← Custom event handlers (Node.js)
│   └── service-impl.java  ← Custom handlers (Java alternative)
├── app/
│   └── fiori-app/         ← Fiori Elements UI (optional)
├── mta.yaml               ← Multi-target application deployment descriptor
└── package.json           ← Node.js dependencies + CDS config

Essential Commands

cds init my-project          # Scaffold new CAP project
cds watch                    # Local dev server with mock data + live reload
cds build                    # Compile CDS → HANA artifacts + OData metadata
cds deploy --to hana         # Deploy DB schema to HANA Cloud
cf push                      # Deploy to Cloud Foundry
mbt build && cf deploy *.mtar # MTA build + deploy (recommended for production)

Custom Handler Patterns (Node.js)

module.exports = cds.service.impl(async function () {
  const db = await cds.connect.to('db');

  // Before hook — validate input
  this.before('CREATE', 'MyEntity', async (req) => {
    if (!req.data.CompanyCode) req.reject(400, 'CompanyCode is required');
  });

  // On hook — custom read logic
  this.on('READ', 'MyEntity', async (req) => {
    return db.run(req.query);
  });

  // Remote service call to S/4HANA
  this.on('getStock', async (req) => {
    const s4 = await cds.connect.to('S4HANA_MM');
    return s4.run(SELECT.from('A_MaterialStock').where({ Plant: req.data.Plant }));
  });
});

3. Fiori Elements Floor Plans

Floor PlanUse CaseKey Annotations
List Report Page (LRP)Search + list view@UI.LineItem, @UI.SelectionFields
Object Page (OP)Detail + edit view@UI.Facets, @UI.FieldGroup
Analytical List Page (ALP)Charts + list@UI.Chart, @UI.PresentationVariant
Worklist Page (WP)Task-oriented list@UI.LineItem (no search area)
Form Entry Object PageData entry form@UI.FieldGroup (editable mode)

OData V4 preferred for all new development on S/4HANA 2022+ and BTP.

Flexible Programming Model: mix Fiori Elements sections with custom SAPUI5 building blocks.

Common CDS UI Annotations

@UI.lineItem: [{ position: 10, label: 'Company Code' }]
@UI.selectionField: [{ position: 10 }]
@UI.fieldGroup: [{ qualifier: 'GeneralInfo', position: 10 }]
@UI.facets: [{ id: 'GeneralInfo', type: #COLLECTION,
               label: 'General Information',
               child: [{ id: 'GeneralData', type: #FIELDGROUP_REFERENCE,
                         targetQualifier: 'GeneralInfo' }] }]

4. Integration Suite (Cloud Platform Integration — CPI)

iFlow Design Patterns

PatternUse Case
Request-ReplySynchronous call to backend; wait for response
Pub/Sub (Event Mesh)Async — publisher doesn't wait; decoupled
BatchScheduled processing; large volume data transfer
AggregatorCollect multiple messages; combine into one

Adapter Types

AdapterProtocol / Use
HTTPREST APIs
SOAPWeb services (legacy)
ODataSAP OData V2/V4 services
SFTPFile-based integration
AMQPMessage queue integration
JDBCDatabase direct access
MailEmail-based integration

Exception Handling

  • Exception subprocess: catches errors within iFlow → send alert / dead letter
  • Dead letter queue: failed messages stored for retry / manual processing
  • Alerting: Alert Notification Service → notify on iFlow failure

5. Side-by-Side Extension Pattern

Architecture

S/4HANA Business Event (e.g., Sales Order Created)
  → SAP Event Mesh (event broker)
    → BTP CAP Application (subscriber / consumer)
      → HANA Cloud (persistence)
        → Fiori Elements UI (user interface)

When to Use Which Extension Approach

ApproachWhenNotes
Key User (Tier 1)Simple field additions, custom logic via BRF+No code, in-app
BTP Side-by-side (Tier 2)Decoupled apps, cloud-native, lifecycle independentCAP + Fiori
On-stack RAP (Tier 3)Tight integration, low latency, on-premise onlyABAP CBO allowed on-premise
ModificationsNever in S/4HANA Cloud; avoid on-premiseUse enhancements instead

6. BTP Security

XSUAA Configuration (xs-security.json)

{
  "xsappname": "my-app",
  "tenant-mode": "dedicated",
  "scopes": [
    { "name": "$XSAPPNAME.read",  "description": "Read access" },
    { "name": "$XSAPPNAME.write", "description": "Write access" }
  ],
  "role-templates": [
    {
      "name": "Viewer",
      "scope-references": ["$XSAPPNAME.read"]
    },
    {
      "name": "Editor",
      "scope-references": ["$XSAPPNAME.read", "$XSAPPNAME.write"]
    }
  ]
}

Destination Service (Never Hardcode Backend URLs)

// Use destination service — never hardcode S/4HANA URL
const s4 = await cds.connect.to('S4HANA_SALES');  // Name matches destination in BTP cockpit
const result = await s4.run(SELECT.from('A_SalesOrder').limit(10));

Principal Propagation

OAuth 2.0 SAML Bearer Assertion flow: SF/S/4HANA user identity passed through to backend → Configure in BTP Destination: Authentication = OAuth2SAMLBearerAssertion


7. Common BTP Errors

ErrorRoot CauseFix
CORS errorMissing origin in XSUAA / approuterAdd allowed origin in xs-app.json
"Destination not found"Name mismatch in code vs BTP cockpitCheck exact destination name (case-sensitive)
"Token expired — 401"OAuth token not refreshedImplement token refresh; check token lifetime config
CDS compilation errorSyntax / reference error in .cds fileCheck entity names, association targets; run cds build locally
CF push failsMemory limit / buildpack / missing service bindingCheck manifest.yml; verify service binding in cf services
Kyma function cold startLow memory allocationIncrease memory; configure min replicas > 0
"Service binding not found"Env variable not injectedCheck CF service binding: cf env my-app

8. S/4HANA Extensibility Tiers

Tier 1 — Key User Extensions (no code, in-app):
  Custom fields → Adapt UI → Custom Logic (BRF+) → Custom Business Objects
  Available in: all S/4HANA deployments including Cloud PE

Tier 2 — Developer Extensions (BTP side-by-side):
  CAP applications → Fiori extensions → Event-driven apps → Integration
  Available in: S/4HANA on-premise, RISE, Cloud PE

Tier 3 — Classic On-premise ABAP (CBO):
  ABAP classes, enhancements, BAdIs, custom programs
  Available in: on-premise and RISE ONLY
  NOT available in: S/4HANA Cloud Public Edition
我的收藏