Code Library
Production-ready code patterns, templates, and snippets for SAP development. Covers ABAP Cloud (RAP), CAP CDS, OData V4 consumption, BTP service bindings, Joule skill SDK, and SAP Build formula patterns.
Overview
The Code Library is a curated collection of production-grade code patterns for the SAP development ecosystem. Unlike documentation, these patterns include annotations explaining the why behind each implementation choice — Clean Core compliance, error handling strategies, security considerations (XSUAA token propagation, principal propagation), and performance optimisations (CDS query push-down, HANA native functions).
Patterns are organised by technology layer. Each pattern links to a fully documented page with the complete code snippet, prerequisites, and deployment notes. All patterns are verified against the current releases: S/4HANA 2025 OP, CAP Node.js 8.x, BTP Q4 2025 services, and ABAP Cloud (S/4HANA ABAP Platform 2023).
Pattern Categories
- RAP BO root entity — CDS View Entity + Behaviour Definition
- ABAP Cloud class — FOR CLOUD DEVELOPMENT language version
- Released BAdI implementation — filter condition, exception handling
- CDS analytical query — @Analytics.query: true with aggregation
- ABAP Unit Test — test class with CUT-based isolation
- Service definition with OData V4 import and projection
- Custom handler — before/on/after hooks with req.user
- S/4HANA delegation — transparent remote service call
- HANA native function call from CDS — $native expression
- CAP Event Mesh — emit domain event and subscribe handler
- Fetch API call with CSRF token and SAP-Client header
- Batch request ($batch) for multiple entity reads
- Deep INSERT — header with items in one POST payload
- $expand with $select for optimised payloads
- OData V4 action invocation with bound action parameters
- XSUAA service binding — fetch JWT token for M2M calls
- Destination Service API — resolve destination at runtime
- SAP AI SDK — Gen AI Hub chat completion with streaming
- SAP AI SDK — Gen AI Hub embedding for RAG pipeline
- HANA Cloud client — node-hdb vs. @sap/hana-client
- Skill descriptor — intent, utterances, and slot definitions
- Handler — callAPI() with principal propagation
- respond() — card, list, confirmation, clarification types
- Multi-turn conversation — context.session state management
- Error handling — fallback message and escalation action
- Data variable — OData V4 collection with live refresh
- Formula navigation — pageVars, appVars, route parameters
- REST API integration — OAuth2 client credentials flow
- Offline data sync — delta token and local storage binding
- Custom component — reusable card with exposed properties