|
| 1 | +# Domain-Driven Architecture with RAP (and contrast to UI-Driven) |
| 2 | + |
| 3 | +**Domain-Driven Design (DDD)** is an architectural approach that models software systems based on real-world business domains. It promotes aligning code with business terminology and processes. |
| 4 | + |
| 5 | +In SAP, the **ABAP RESTful Application Programming Model (RAP)** applies domain-driven principles to build enterprise applications on S/4HANA. |
| 6 | + |
| 7 | +This page explains how RAP embodies Domain-Driven Architecture — and how **abap2UI5 takes a fundamentally different approach**. |
| 8 | + |
| 9 | +--- |
| 10 | + |
| 11 | +## What is Domain-Driven Architecture? |
| 12 | + |
| 13 | +Key principles of Domain-Driven Design: |
| 14 | +- **Domain Models**: Represent business entities & relationships. |
| 15 | +- **Bounded Contexts**: Isolated domain-specific models with clear interfaces. |
| 16 | +- **Ubiquitous Language**: Shared business terminology in models & code. |
| 17 | +- **Separation of Concerns**: Domain logic separated from UI & infrastructure. |
| 18 | + |
| 19 | +In SAP, this typically translates to: |
| 20 | +- CDS Views & Entities as Domain Models. |
| 21 | +- Behaviors for domain-specific processes. |
| 22 | +- Typed OData Services for structured interfaces. |
| 23 | + |
| 24 | +--- |
| 25 | + |
| 26 | +## Domain-Driven Design in RAP |
| 27 | + |
| 28 | +### Domain Models |
| 29 | +- Modeled using **CDS Views** (Root & Composite Entities). |
| 30 | +- Reflect business concepts like `SalesOrder`, `BusinessPartner`. |
| 31 | +- Data model is defined **at design-time** via CDS. |
| 32 | + |
| 33 | +### Behaviors & Processes |
| 34 | +- Modeled through **Behavior Definitions** (Managed/Unmanaged). |
| 35 | +- Actions like `Submit`, `Approve`, `Cancel` represent domain logic. |
| 36 | +- Draft handling, validations, side effects handled by RAP runtime. |
| 37 | + |
| 38 | +### Bounded Contexts & Service Projections |
| 39 | +- Service Projections define clear boundaries per domain. |
| 40 | +- Typed OData V4 APIs expose domain models & behaviors. |
| 41 | + |
| 42 | +### UI Integration |
| 43 | +- Fiori Elements renders UIs based on OData metadata & annotations. |
| 44 | +- UI structure is derived from the domain model (Domain → UI). |
| 45 | + |
| 46 | +--- |
| 47 | + |
| 48 | +## Limitations of RAP's Domain-Driven Approach |
| 49 | +- **Data models are static**: Defined via CDS at design-time. |
| 50 | +- **UI reflects the domain model structure**: Flexible adjustments at runtime are limited. |
| 51 | +- Dynamic use cases (e.g., changing data schemas at runtime) are not feasible. |
| 52 | +- Strong governance ensures stability but reduces runtime flexibility. |
| 53 | + |
| 54 | +--- |
| 55 | + |
| 56 | +## Contrast: abap2UI5's UI-driven, Dynamic Approach |
| 57 | + |
| 58 | +In contrast to RAP's domain-first architecture, **abap2UI5 follows a UI-driven pattern** with high runtime flexibility: |
| 59 | + |
| 60 | +### Key Differences: |
| 61 | +- **UI5 View Definitions are central**: The UI is designed first, independent of the backend data model. |
| 62 | +- **Backend supplies XML Views & ViewModels dynamically**. |
| 63 | +- Data models can be **swapped or constructed dynamically at runtime**. |
| 64 | +- Technologies like **RTTI (Runtime Type Information)** enable dynamic data handling. |
| 65 | +- No dependency on design-time CDS models. |
| 66 | +- UI logic and structure are controlled in ABAP at runtime. |
| 67 | + |
| 68 | +### Why is this different from RAP? |
| 69 | +| Aspect | RAP (Domain-Driven) | abap2UI5 (UI-Driven, Dynamic) | |
| 70 | +|--------|---------------------|------------------------------| |
| 71 | +| **Data Model Definition** | CDS Views (design-time) | ViewModel built dynamically in ABAP | |
| 72 | +| **UI Definition** | Based on domain model (annotations) | XML View controlled directly in ABAP | |
| 73 | +| **Runtime Flexibility** | Limited, strictly typed | High: dynamic ViewModel, RTTI possible | |
| 74 | +| **Frontend Rendering** | Fiori Elements SPA builds UI from metadata | Static UI5 shell renders backend-provided View | |
| 75 | +| **Typical Use Cases** | Stable, transactional apps | Dynamic UIs, prototypes, tools, flexible CRUD apps | |
| 76 | + |
| 77 | +--- |
| 78 | + |
| 79 | +## Summary |
| 80 | + |
| 81 | +- **RAP** applies Domain-Driven principles by strictly defining data models, behaviors, and services at design-time. |
| 82 | +- This ensures robust, structured applications aligned with business domains. |
| 83 | +- However, it limits runtime flexibility and dynamic UI adaptations. |
| 84 | + |
| 85 | +- **abap2UI5**, in contrast, prioritizes UI-driven development with flexible View & ViewModel handling at runtime. |
| 86 | +- Data models can be built or replaced dynamically, allowing agile, backend-controlled UI composition without CDS dependencies. |
| 87 | + |
| 88 | +Both approaches serve different purposes: |
| 89 | +- **RAP**: Structured, enterprise-grade transactional apps. |
| 90 | +- **abap2UI5**: Flexible, backend-driven UI development for scenarios where dynamic behavior & rapid iterations are key. |
| 91 | + |
| 92 | +--- |
| 93 | + |
| 94 | +## Further Reading |
| 95 | +- [Domain-Driven Design Quickly (DDD Summary)](https://dddcommunity.org/resources/) |
| 96 | +- [ABAP RESTful Application Programming Model (RAP)](https://help.sap.com/docs/abap-cloud/abap-restful-application-programming-model) |
| 97 | +- [abap2UI5 Documentation](https://abap2ui5.github.io/docs/) |
| 98 | +- [Ubiquitous Language in DDD](https://martinfowler.com/bliki/UbiquitousLanguage.html) |
| 99 | +- [SAP Clean Core Approach](https://community.sap.com/topics/clean-core) |
0 commit comments