0% found this document useful (0 votes)
27 views5 pages

ABAP RESTful Application Programming Model (RAP) With Example

The ABAP RESTful Application Programming Model (RAP) is SAP's framework for building OData services on SAP S/4HANA, encompassing database modeling, business logic, service definition, and Fiori UI integration. The document outlines the key components of RAP, including layers for data modeling, behavior, service, UI, and extensibility, along with a step-by-step example for creating an Employee Management App. It highlights the resulting capabilities such as CRUD operations and automated Fiori UI generation, while also suggesting next steps for enhancing the application.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
27 views5 pages

ABAP RESTful Application Programming Model (RAP) With Example

The ABAP RESTful Application Programming Model (RAP) is SAP's framework for building OData services on SAP S/4HANA, encompassing database modeling, business logic, service definition, and Fiori UI integration. The document outlines the key components of RAP, including layers for data modeling, behavior, service, UI, and extensibility, along with a step-by-step example for creating an Employee Management App. It highlights the resulting capabilities such as CRUD operations and automated Fiori UI generation, while also suggesting next steps for enhancing the application.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

ABAP RESTful Application Programming Model (RAP) with Example

ABAP RAP is SAP’s recommended way to build enterprise-ready OData services on


SAP S/4HANA. It provides a consistent end-to-end programming model that
covers database modeling, business logic (behavior), service definition, and Fiori
UI integration.

1. RAP Layers and Artifacts

Layer Object Type Example Name

Database table Transparent table ZEMPLOYEE

Data modeling CDS view (Projection) ZEMPLOYEE_PR

Behavior definition Behavior definition ZEMPLOYEE_BEH

Service definition Service definition ZEMPLOYEE_SRV

Service binding OData binding ZEMPLOYEE_BIND

2. Step-by-Step Example: Employee Management App

2.1 Create Database Table

@EndUserText.label : 'Employee Table'

@AbapCatalog.tableCategory : #TRANSPARENT

define table ZEMPLOYEE {

key ID : abap.int4;

NAME : abap.string(50);

DEPARTMENT : abap.string(50);

2.2 Define CDS Projection View

This view exposes only the fields needed by the service and UI.

@EndUserText.label: 'Employee Projection'

@AccessControl.authorizationCheck: #NOT_REQUIRED

define view entity ZEMPLOYEE_PR

as projection on ZEMPLOYEE {

key ID,

NAME,
DEPARTMENT

2.3 Extend UI Metadata

Annotations for Fiori Elements list and object page.

@Metadata.layer: #CORE

extend view entity ZEMPLOYEE_PR with ZEMPLOYEE_UI {

@UI.lineItem: [{ position: 10 }]

ID;

@UI.lineItem: [{ position: 20 }]

NAME;

@UI.lineItem: [{ position: 30 }]

DEPARTMENT;

2.4 Define Behavior

A managed scenario that handles create, update, and delete for the transparent
table.

define behavior for ZEMPLOYEE_PR alias Employee

persistent table ZEMPLOYEE

create;

update;

delete;

2.5 Service Definition

Expose the projection as an OData entity.

define service ZEMPLOYEE_SRV {

expose ZEMPLOYEE_PR as Employee;

2.6 Service Binding and Activation


1. In /iwfnd/maint_service choose Add Service.

2. Select ZEMPLOYEE_SRV and create a new OData V2 or V4 binding (e.g.,


ZEMPLOYEE_BIND).

3. Assign to your system alias and activate.

4. Launch the Fiori Elements preview for CRUD operations.

3. Resulting Capabilities

 Full Create, Read, Update, Delete on Employee records

 Automated Fiori List Report and Object Page

 Seamless integration with SAP Fiori and SAPUI5

Next Steps

 Enable draft handling for offline edits

 Add custom actions (for example, “PromoteEmployee”)

 Implement approval workflows using RAP action handlers

 Integrate with BAPIs or external OData services

Feel free to dive deeper into any of these extensions or ask for an unmanaged
scenario example!

Let’s break down its key components in a structured way so you can see how
they fit together in building scalable, enterprise-grade apps.

🧩 Core Components of ABAP RAP

1. Data Modeling Layer

 Database Tables: Define persistent storage (e.g., ZEMPLOYEE).

 CDS View Entities: Represent business objects with annotations for UI,
behavior, and service exposure.

 Projection Views: Tailor CDS views for specific service or UI needs.

2. Behavior Layer

 Behavior Definitions (BDEF): Declare what operations (create, update,


delete, actions) are allowed.

 Behavior Implementations (BIMPL): Implement the logic behind those


operations using ABAP classes.
 Managed vs Unmanaged Scenarios:

o Managed: RAP handles standard operations automatically.

o Unmanaged: You write custom logic for everything.

3. Service Layer

 Service Definition: Exposes CDS views and behaviors as OData entities.

 Service Binding: Connects the service to a protocol (OData V2/V4) and


enables Fiori preview.

4. UI Layer

 Metadata Extensions: Add UI annotations like line items, field groups,


and labels.

 Fiori Elements: Auto-generate UI based on annotations—no need for


custom SAPUI5 code.

5. Transactional Engine

 Entity Manipulation Language (EML): ABAP syntax for interacting with


RAP business objects.

 Draft Handling: Supports save-as-draft and versioning for complex


workflows.

 Validations & Determinations: Logic hooks for checking and deriving


data during transactions.

6. Extensibility & Events

 Business Events: Trigger asynchronous processes (e.g., notifications).

 Whitelisted APIs: Ensure upgrade-safe interactions with standard SAP


objects.

🧠 How It All Comes Together

Imagine you’re building a Fiori app to manage employee data:

 You start with a CDS view entity on ZEMPLOYEE.

 Define a behavior to allow CRUD operations.

 Expose it via a service definition and bind it.

 Add UI annotations to control how fields appear.

 Use Fiori Elements to preview and deploy the app.


Would you like a visual diagram of this flow or a deeper dive into managed vs
unmanaged scenarios? I can also help you scaffold a RAP project from scratch if
you're planning one!

You might also like