RAP Unmanaged Scenario Concepts with Examples
This document explains the RAP (RESTful ABAP Programming Model) Unmanaged Scenario concepts
with examples.
1. Introduction to RAP Unmanaged
• In an Unmanaged scenario, the data persistence and transactional logic are handled manually by
the developer.
• Unlike Managed RAP, SAP does not generate CRUD logic automatically.
• Useful when:
• Business logic is complex.
• Legacy tables or custom persistence must be integrated.
• Migration projects from classic ABAP.
2. Key Concepts
🔹 2.1 Data Model
• Interface View (Root / Child Entity): Defines the data model.
• Projection View: Exposes the model to UI/service.
Example – Interface View:
@EndUserText.label: 'Sales Order Root Entity'
@ObjectModel:
{ transactionalProcessingEnabled: true,
compositionRoot: true }
define root view entity ZI_SalesOrder
as select from zso_hdr
{
key so_id,
customer,
created_by,
created_at
}
Child Entity (Items):
1
@ObjectModel.compositionRoot: false
@ObjectModel.compositionChild: true
define view entity ZI_SalesOrderItem
as select from zso_item
{
key item_id,
parent_so_id as so_id,
material,
quantity
}
🔹 2.2 Behavior Definition
In unmanaged, you declare behavior but implement logic in classes.
unmanaged implementation in class ZBP_SalesOrder unique
define behavior for ZI_SalesOrder alias SalesOrder
persistent table zso_hdr
lock master
create;
update;
delete;
association _Items { create; }
endbehavior.
Child Behavior:
define behavior for ZI_SalesOrderItem alias SalesOrderItem
persistent table zso_item
lock dependent by SalesOrder
create;
update;
delete;
endbehavior.
2
🔹 2.3 Behavior Implementation Class
Here, you implement CRUD operations explicitly.
CLASS zbp_salesorder DEFINITION PUBLIC FINAL CREATE PUBLIC.
PUBLIC SECTION.
INTERFACES: if_rap_unmanaged_bp.
ENDCLASS.
CLASS zbp_salesorder IMPLEMENTATION.
METHOD if_rap_unmanaged_bp~create.
LOOP AT entities INTO DATA(ls_entity).
INSERT VALUE zso_hdr( so_id = ls_entity-so_id
customer = ls_entity-customer )
INTO zso_hdr.
ENDLOOP.
ENDMETHOD.
METHOD if_rap_unmanaged_bp~update.
LOOP AT entities INTO DATA(ls_entity).
UPDATE zso_hdr SET customer = ls_entity-customer
WHERE so_id = ls_entity-so_id.
ENDLOOP.
ENDMETHOD.
METHOD if_rap_unmanaged_bp~delete.
LOOP AT keys INTO DATA(ls_key).
DELETE FROM zso_hdr WHERE so_id = ls_key-so_id.
ENDLOOP.
ENDMETHOD.
ENDCLASS.
🔹 2.4 Determinations
• Executed automatically during specific events (create, update).
Example:
METHOD determination_set_created_by.
LOOP AT entities INTO DATA(ls_entity).
ls_entity-created_by = sy-uname.
MODIFY entities FROM ls_entity.
3
ENDLOOP.
ENDMETHOD.
🔹 2.5 Validations
• Used to validate data before persistence.
Example:
METHOD validation_check_customer.
LOOP AT entities INTO DATA(ls_entity).
IF ls_entity-customer IS INITIAL.
APPEND VALUE #( %key-so_id = ls_entity-so_id
%msg = new_message( id = 'ZMSG'
number = '001'
severity =
if_abap_behv_message=>severity-error ) )
TO reported.
ENDIF.
ENDLOOP.
ENDMETHOD.
🔹 2.6 Actions
• Custom operations triggered explicitly.
Behavior Definition:
action confirmOrder result [1] $self;
Implementation:
METHOD confirmOrder.
LOOP AT keys INTO DATA(ls_key).
UPDATE zso_hdr SET status = 'CONFIRMED'
WHERE so_id = ls_key-so_id.
ENDLOOP.
ENDMETHOD.
4
🔹 2.7 Authorizations
• Implement custom authorization checks.
Example:
METHOD get_authorizations.
LOOP AT requested_authorizations INTO DATA(req).
IF req-%action = 'UPDATE' AND sy-uname <> 'ADMIN'.
APPEND VALUE #( %key-so_id = req-%key-so_id
%msg = new_message( id = 'ZMSG'
number = '002'
severity =
if_abap_behv_message=>severity-error ) )
TO reported.
ENDIF.
ENDLOOP.
ENDMETHOD.
🔹 2.8 Locking
• Handled via lock master or lock dependent in behavior definition.
• You must implement lock logic if required.
3. Summary
• Unmanaged RAP requires the developer to handle persistence logic (CRUD).
• Key elements include:
• Data Model (Interface/Projection views)
• Behavior Definition
• Behavior Implementation (CRUD, actions, determinations, validations, authorizations)
• Suitable when standard managed scenario cannot handle complex or legacy persistence.
✅ With this, you have the full RAP Unmanaged Scenario overview with examples.