RAPIntermediate•1 min read•Calculating progress…•Aug 15, 2026

Getting Started with ABAP Cloud & SAP RESTful Application Programming Model (RAP)

A complete step-by-step guide to building clean, cloud-ready SAP applications using ABAP RESTful Application Programming Model (RAP) on SAP BTP and S/4HANA.

K Sai Bhaskar
K Sai Bhaskar
Consultant
Loading…
Getting Started with ABAP Cloud & SAP RESTful Application Programming Model (RAP)

Getting Started with ABAP Cloud & SAP RESTful Application Programming Model (RAP)

ABAP Cloud is the modern development model for SAP S/4HANA and SAP BTP ABAP Environment. At its heart lies the RESTful Application Programming Model (RAP), designed to build transactional, cloud-native OData services seamlessly.

//1. Introduction to ABAP Cloud

With SAP S/4HANA, traditional ABAP programming patterns (such as direct database modifications via MODIFY ztable inside SAPGUI screens) are superseded by strict released APIs and business object frameworks.
Key tenets of ABAP Cloud:
  • •Clean Core Strategy: No direct modifications to standard SAP objects.
  • •Strict ABAP Syntax: Cloud-enabled ABAP rules with restricted language scope.
  • •CDS-first Data Modeling: Core Data Services drive entity relationships.

//2. RAP Architecture Overview

RAP segregates applications into distinct architectural layers:
  1. 1.Data Model Layer: CDS Data Definitions (Root View Entities & Projection Views).
  2. 2.Behavior Layer: Behavior Definitions (BDEF) and Behavior Implementations (ABAP Class).
  3. 3.Service Layer: Service Definition (SRVD) and Service Binding (SRVB).

//3. Creating Data Model (CDS View)

Define your root view entity for a Sales Order header:
abap
1@AccessControl.authorizationCheck: #NOT_REQUIRED
2@EndUserText.label: 'Sales Order Header View'
3define root view entity ZR_SalesOrderTP
4 as select from zso_header
5 composition [0..*] of ZR_SalesOrderItemTP as _Item
6{
7 key order_uuid as OrderUUID,
8 order_id as OrderID,
9 customer_id as CustomerID,
10 order_status as OrderStatus,
11 total_amount as TotalAmount,
12 currency_code as CurrencyCode,
13
14 /* Associations */
15 _Item
16}

//4. Behavior Definition (BDEF)

Specify standard CRUD capabilities (create, update, delete) and custom actions:
abap
1managed implementation in class zbp_r_salesordertp unique;
2strict ( 2 );
3
4define behavior for ZR_SalesOrderTP alias SalesOrder
5persistent table zso_header
6lock master
7authorization master ( instance )
8{
9 create;
10 update;
11 delete;
12
13 field ( readonly, numbering : managed ) OrderUUID;
14 field ( readonly ) OrderStatus;
15
16 action ( features : instance ) approveOrder result [1] $self;
17
18 mapping for zso_header
19 {
20 OrderUUID = order_uuid;
21 OrderID = order_id;
22 CustomerID = customer_id;
23 OrderStatus = order_status;
24 TotalAmount = total_amount;
25 CurrencyCode = currency_code;
26 }
27}

//5. Behavior Implementation (ABAP Class)

Implement the custom approveOrder action using EML (Entity Manipulation Language):
abap
1CLASS lhc_SalesOrder DEFINITION INHERITING FROM cl_abap_behavior_handler.
2 PRIVATE SECTION.
3 METHODS approveOrder FOR MODIFY
4 IMPORTING keys FOR ACTION SalesOrder~approveOrder RESULT result.
5ENDCLASS.
6
7CLASS lhc_SalesOrder IMPLEMENTATION.
8 METHOD approveOrder.
9 " Modify entity status via EML
10 MODIFY ENTITIES OF ZR_SalesOrderTP IN LOCAL MODE
11 ENTITY SalesOrder
12 UPDATE FIELDS ( OrderStatus )
13 WITH VALUE #( FOR key IN keys ( OrderUUID = key-OrderUUID
14 OrderStatus = 'APPROVED' ) )
15 FAILED failed
16 REPORTED reported.
17
18 " Read updated values for action result
19 READ ENTITIES OF ZR_SalesOrderTP IN LOCAL MODE
20 ENTITY SalesOrder
21 ALL FIELDS WITH CORRESPONDING #( keys )
22 RESULT DATA(lt_orders).
23
24 result = VALUE #( FOR order IN lt_orders ( %tky = order-%tky %param = order ) ).
25 ENDMETHOD.
26ENDCLASS.

//6. Preview & Testing in Fiori Elements

Publish a Service Definition and generate a Service Binding (OData V4). ADT (ABAP Development Tools in Eclipse) provides an integrated SAP Fiori Elements Preview tool to interactively test your full-stack application!
Attachments (3)
Loading…
Figure 1.1: RAP Architectural Layer Overview
Figure 1.1: RAP Architectural Layer Overview
Loading…
Figure 1.2: ADT Eclipse Preview of Behavior Definition
Figure 1.2: ADT Eclipse Preview of Behavior Definition
Loading…
Figure 1.3: Fiori Elements Preview App Execution
Figure 1.3: Fiori Elements Preview App Execution
// Tags:#RAP#ABAP Cloud#CDS#BDEF#SAP BTP
Lead SAP Architect & Instructor
K Sai Bhaskar

K Sai Bhaskar

Consultant

Passionate SAP Consultant with 4+ years of experience in SAP ABAP, S/4HANA, CDS Views, RAP, and ABAP Cloud, delivering efficient business solutions.

Verified SAP Certifications:
✓ SAP Certified - Backend Developer - ABAP Cloud

Comments & Community Discussion0

Ask questions, share SAP insights, and discuss ABAP implementation details.

Moderated & Spam-Protected
LinksText
0/2000
Loading discussions…

Related Tutorials in this Track

K Sai Bhaskar

More Guides from this Author

Consultant • SAP Certified - Backend Developer - ABAP Cloud

Explore All Tutorials