WTF Solution

What is SAP RAP (RESTful Application Programming) for Beginner in 2025?

The ABAP RESTful Application Programming Model (RAP) is SAP's modern, standardized framework for building cloud-ready, enterprise-grade business applications and OData services on the SAP platform. It is a key element of ABAP Cloud and is used for development on SAP BTP (Business Technology Platform), SAP S/4HANA Cloud, and SAP S/4HANA.

RAP is a modern development process for creating ABAP objects. Using RAP, you can develop a Report, a Custom Screen, ODATA, and an API. It follows a Clean Core rule and cloud-ready approach. It supports both SAP S/4HANA Private and Public Cloud, as well as SAP BTP.


🏗️ Architecture and Core Components

RAP enforces a layered architecture to ensure a clean separation of concerns, built upon ABAP Core Data Services (CDS), the extended ABAP language, and modern tools like the ABAP Development Tools (ADT) in Eclipse.

1. Data Modeling and Persistence Layer

This layer focuses on defining the structure of the business data.

  • Database Table: The underlying persistence layer for transactional or master data.
  • Core Data Services (CDS) View Entities: These are the foundation of the RAP data model.
    • Interface/Root View: Defines the fundamental data model and structure of the Business Object (BO), including associations and compositions (parent-child relationships).
    • Projection/Consumption View: A view on top of the root view that projects or exposes a subset of the fields. It is the artifact used for consumption and where UI-specific annotations (@UI) are added.

2. Business Logic Layer (Behavior)

This layer defines what can be done with the data model.

  • Behavior Definition (BDL): Declares the allowed operations on the Business Object. This includes:
    • Standard Operations: create, update, delete (CRUD).
    • Non-Standard Operations (Actions): Custom business operations (e.g., "Set Status to Approved," "Calculate Tax").
    • Validations: Checks for business rules before execution.
    • Determinations: Calculations or logic executed automatically during a transaction (e.g., auto-calculate the total price).
    • Draft Handling: Defines how inconsistent data can be temporarily saved on the database.
  • Behavior Implementation (ABAP Class): An ABAP class where the logic for the non-standard operations, validations, and custom persistence (in unmanaged scenarios) is implemented.

RAP offers two main implementation types:

TypeDescription
ManagedThe RAP framework automatically handles all standard CRUD operations and data persistence. Developers only implement custom logic (actions, validations). Ideal for greenfield (new) development.
UnmanagedDevelopers write all the logic for CRUD operations and persistence (using ABAP and Entity Manipulation Language - EML). Typically used for brownfield scenarios, integrating with existing custom logic, or leveraging standard SAP APIs (BAPIs/APIs).

3. Service Exposure and Consumption Layer

This layer exposes the business object as a service consumable by a client.

  • Service Definition: Specifies which CDS entities (projection views) and behaviors should be exposed as part of the RESTful service.
  • Service Binding: Defines the technical communication protocol (e.g., OData V4 UI for Fiori Elements apps or OData V4 Web API for external systems) and publishes the service endpoint.
  • Service Consumption (Client): The exposed service is consumed by clients like an SAP Fiori Elements application (which uses the annotations in the CDS projection views to generate the UI) or any external OData consumer.

📝 Example Scenario: Travel Booking App

A common use case for RAP is creating a transactional application to manage business data, such as a Travel Booking App where an employee can create, update, and manage their travel requests.

RAP ArtifactDescription/Content
Database TableZTB_TRAVEL (Stores travel header data like Employee ID, Start/End Date, Status).
Root CDS ViewZI_TRAVEL_R (Selects data from ZTB_TRAVEL, defines a composition to ZI_BOOKING_R).
Projection CDS ViewZC_TRAVEL_R (Selects from ZI_TRAVEL_R, adds UI Annotations (@UI.lineItem, @UI.facet) to define how the data looks in the Fiori List Report/Object Page).
Behavior DefinitionI_TRAVEL_R.bdef (Declares managed implementation, includes Validation for checking valid dates, and an Action called set_status_approved).
Behavior ClassZBP_I_TRAVEL_R (Implements the custom logic for the Validation and the set_status_approved Action).
Service DefinitionZSD_TRAVEL (Exposes the projection views ZC_TRAVEL_R and ZC_BOOKING_R).
Service BindingZSB_TRAVEL_V4_UI (Binds ZSD_TRAVEL to OData V4 UI).

The resulting application, generated automatically by SAP Fiori Elements, would allow users to:

  1. Create a new travel request (handled by the managed RAP runtime).
  2. View a list of all travel requests (handled by the read query).
  3. Validate dates when saving (using the custom ABAP logic in the Validation).
  4. Click an "Approve" button to execute the custom Action (set_status_approved).

This video provides an overview of the ABAP RESTful Application Programming Model (RAP) and its quality attributes for building future-ready SAP applications: What Is the ABAP RESTful Application Programming Model (ABAP RAP)?

Read More - Naming Conventions for SAP RAP Objects, Useful ABAP Cloud Syntax for SAP S/4Hana Cloud

Leave a Reply

Your email address will not be published. Required fields are marked *

Scroll to Top