Guides RAP (RESTful ABAP Programming Model) development: behavior definitions, EML, managed/unmanaged BOs, draft, actions, validations, determinations, side effects, and business events for ABAP Cloud Fiori apps.
How this skill is triggered — by the user, by Claude, or both
Slash command
/sap-fiori-url-generator:rapThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Guide for building transactional applications using the ABAP RESTful Application Programming Model (RAP) in ABAP Cloud.
Guide for building transactional applications using the ABAP RESTful Application Programming Model (RAP) in ABAP Cloud.
Determine the user's goal:
Identify the scenario:
Guide implementation following the RAP layered architecture:
Provide code examples using correct BDL and EML syntax
| Layer | Artifacts | Purpose |
|---|---|---|
| Data Modeling | Database tables, CDS root/child view entities | Data persistence and semantic data model |
| Behavior Definition | BDEF (.bdef) | Declares transactional behavior (operations, characteristics) using BDL |
| Behavior Implementation | ABAP behavior pool (BP_*) | Implements business logic in handler/saver classes |
| Projection | CDS projection views, projection BDEF | Adapts BO for specific service consumers |
| Business Service | Service definition, service binding | Exposes BO as OData service |
additional save or replaced with unmanaged save)managed implementation in class zbp_r_entity unique;
strict ( 2 );
unmanaged implementation in class zbp_r_entity unique;
strict ( 2 );
managed implementation in class zbp_r_root unique;
strict ( 2 );
with draft;
define behavior for ZR_Root alias Root
persistent table zroot_tab
draft table zroot_d
etag master LocalLastChangedAt
lock master
total etag LastChangedAt
authorization master ( global )
late numbering
{
// Field characteristics
field ( readonly ) RootUUID, CreatedBy, CreatedAt, LastChangedBy, LastChangedAt;
field ( mandatory ) Description;
field ( numbering : managed ) RootUUID;
// Standard operations
create;
update;
delete;
// Association to child entity
association _Child { create; }
// Actions
action doSomething result [1] $self;
static action createFromTemplate parameter ZD_CreateParam result [1] $self;
internal action recalculate;
// Validations
validation validateDescription on save { create; field Description; }
// Determinations
determination setDefaults on modify { create; }
determination calcTotal on modify { field Quantity, Price; }
// Draft actions
draft action Resume;
draft action Edit;
draft action Activate optimized;
draft action Discard;
draft determine action Prepare
{
validation validateDescription;
}
// Side effects
side effects
{
field Quantity affects field TotalAmount;
field Price affects field TotalAmount;
determine action Prepare executed on field Description affects messages;
}
// Events
event created;
event deleted parameter ZD_DeletedEvent;
// Mapping
mapping for zroot_tab corresponding
{
RootUUID = root_uuid;
Description = description;
}
}
define behavior for ZR_Child alias Child
persistent table zchild_tab
draft table zchild_d
etag master LocalLastChangedAt
lock dependent by _Root
authorization dependent by _Root
{
field ( readonly ) ChildUUID, RootUUID;
field ( numbering : managed ) ChildUUID;
update;
delete;
association _Root;
mapping for zchild_tab corresponding
{
ChildUUID = child_uuid;
RootUUID = root_uuid;
}
}
projection;
strict ( 2 );
use draft;
define behavior for ZC_Root alias Root
{
use create;
use update;
use delete;
use action doSomething;
use association _Child { create; }
}
define behavior for ZC_Child alias Child
{
use update;
use delete;
use association _Root;
}
| Element | Syntax | Purpose |
|---|---|---|
| Managed numbering | field ( numbering : managed ) KeyField; | Framework assigns UUID keys automatically |
| Early numbering | early numbering | Custom key assignment in interaction phase via FOR NUMBERING handler |
| Late numbering | late numbering | Key assignment in save sequence via adjust_numbers saver method |
| Lock master | lock master | Root entity controls pessimistic locking |
| Lock dependent | lock dependent by _Assoc | Child entity delegates locking to parent |
| ETag | etag master FieldName | Optimistic concurrency control |
| Total ETag | total etag FieldName | Required for draft-enabled BOs |
| Draft | with draft; | Enables draft handling for entire BO |
| Collaborative draft | with collaborative draft; | Multi-user draft editing |
| Strict mode | strict ( 2 ); | Enables additional BDL syntax checks (use latest version) |
CLASS lhc_root DEFINITION INHERITING FROM cl_abap_behavior_handler.
PRIVATE SECTION.
" Standard operations (unmanaged only)
METHODS create FOR MODIFY
IMPORTING entities FOR CREATE Root.
" Action implementation
METHODS doSomething FOR MODIFY
IMPORTING keys FOR ACTION Root~doSomething RESULT result.
" Validation
METHODS validateDescription FOR VALIDATE ON SAVE
IMPORTING keys FOR Root~validateDescription.
" Determination
METHODS setDefaults FOR DETERMINE ON MODIFY
IMPORTING keys FOR Root~setDefaults.
" Instance feature control
METHODS get_instance_features FOR INSTANCE FEATURES
IMPORTING keys REQUEST requested_features FOR Root RESULT result.
" Instance authorization
METHODS get_instance_authorizations FOR INSTANCE AUTHORIZATION
IMPORTING keys REQUEST requested_authorizations FOR Root RESULT result.
ENDCLASS.
CLASS lhc_root IMPLEMENTATION.
METHOD doSomething.
" Read current instance data
READ ENTITIES OF zr_root IN LOCAL MODE
ENTITY Root
ALL FIELDS WITH CORRESPONDING #( keys )
RESULT DATA(entities)
FAILED failed.
" Modify instances
MODIFY ENTITIES OF zr_root IN LOCAL MODE
ENTITY Root
UPDATE FIELDS ( Status )
WITH VALUE #( FOR entity IN entities
( %tky = entity-%tky
Status = 'DONE'
%control-Status = if_abap_behv=>mk-on ) )
FAILED failed
REPORTED reported.
" Fill result
result = VALUE #( FOR entity IN entities
( %tky = entity-%tky
%param = entity ) ).
ENDMETHOD.
METHOD validateDescription.
READ ENTITIES OF zr_root IN LOCAL MODE
ENTITY Root
FIELDS ( Description ) WITH CORRESPONDING #( keys )
RESULT DATA(entities).
LOOP AT entities INTO DATA(entity).
IF entity-Description IS INITIAL.
APPEND VALUE #( %tky = entity-%tky ) TO failed-root.
APPEND VALUE #( %tky = entity-%tky
%msg = new_message_with_text(
severity = if_abap_behv_message=>severity-error
text = 'Description must not be empty' )
%element-Description = if_abap_behv=>mk-on
) TO reported-root.
ENDIF.
ENDLOOP.
ENDMETHOD.
METHOD setDefaults.
READ ENTITIES OF zr_root IN LOCAL MODE
ENTITY Root
ALL FIELDS WITH CORRESPONDING #( keys )
RESULT DATA(entities).
MODIFY ENTITIES OF zr_root IN LOCAL MODE
ENTITY Root
UPDATE FIELDS ( Status CreatedAt )
WITH VALUE #( FOR entity IN entities
( %tky = entity-%tky
Status = 'NEW'
%control-Status = if_abap_behv=>mk-on ) )
REPORTED reported.
ENDMETHOD.
ENDCLASS.
CLASS lsc_root DEFINITION INHERITING FROM cl_abap_behavior_saver.
PROTECTED SECTION.
METHODS finalize REDEFINITION.
METHODS check_before_save REDEFINITION.
METHODS save_modified REDEFINITION.
METHODS cleanup REDEFINITION.
METHODS cleanup_finalize REDEFINITION.
ENDCLASS.
CLASS lsc_root IMPLEMENTATION.
METHOD finalize.
" Final calculations before save
ENDMETHOD.
METHOD check_before_save.
" Final consistency checks
ENDMETHOD.
METHOD save_modified.
" Only needed for 'with additional save' or 'with unmanaged save'
" Raise business events here
IF create-root IS NOT INITIAL.
RAISE ENTITY EVENT zr_root~created
FROM VALUE #( FOR <cr> IN create-root
( %key = VALUE #( RootUUID = <cr>-RootUUID ) ) ).
ENDIF.
ENDMETHOD.
METHOD cleanup.
" Clear transactional buffer
ENDMETHOD.
METHOD cleanup_finalize.
" Rollback finalize changes on failure
ENDMETHOD.
ENDCLASS.
EML is the ABAP language for programmatically interacting with RAP BOs. Key operations: MODIFY ENTITY (create/update/delete/execute action), READ ENTITIES, COMMIT ENTITIES, ROLLBACK ENTITIES.
MODIFY ENTITY ... CREATE FIELDS ( ... ) WITH VALUE #( ( %cid = '...' ... ) )READ ENTITIES OF ... ALL FIELDS WITH VALUE #( ( key = val ) ) RESULT DATA(result)MODIFY ENTITY ... UPDATE FIELDS ( ... ) WITH VALUE #( ( %tky = ... ) )MODIFY ENTITY ... DELETE FROM VALUE #( ( %tky = ... ) )MODIFY ENTITY ... EXECUTE actionName FROM VALUE #( ( %tky = ... ) )CREATE BY \_Assoc with %cid_ref and %targetFor full EML syntax with code examples, read references/eml-quick-reference.md.
with draft; in BDEF headerdraft table for each entity"%admin": include sych_bdl_draft_admin_inc;Edit, Activate, Discard, Resume, Prepare) are implicitly provided%is_draft component (or %tky which includes it) to distinguish draft vs. active instances| Phase | Methods Called | Purpose |
|---|---|---|
| Early Save | finalize → check_before_save → (on failure: cleanup_finalize) | Ensure data consistency |
| Late Save | adjust_numbers → save / save_modified → cleanup | Persist data to database |
| Component | Purpose |
|---|---|
%cid | Content ID — unique preliminary identifier for new instances |
%cid_ref | Reference to a %cid in the same EML request |
%key | Primary key fields |
%tky | Transactional key (%key + %is_draft + %pid) — recommended |
%data | All key and data fields |
%control | Flags indicating which fields are provided/requested |
%is_draft | Draft indicator (draft-enabled BOs only) |
%pid | Preliminary ID (late numbering only) |
%target | Target instances for create-by-association |
%param | Action/function parameter values |
strict ( 2 ); for new BOs%tky over %key for future-proof code (handles draft/late numbering transitions)%cid in create operations even if not referenced laterIN LOCAL MODE in handler methods to bypass feature controls and authorization checksnpx claudepluginhub likweitan/abap-skills --plugin sap-fiori-url-generatorGenerates RAP determination, validation, and custom action implementations by reading the RAP stack and filling empty method stubs in the behavior pool. Use when asked to implement RAP logic or generate custom action code.
Guides implementation of event-driven patterns with RAP business events and SAP Event Mesh in ABAP Cloud, including event definitions, raising events, bindings, and consumption.
Assists with ABAP code for SAP systems: internal tables, structures, ABAP SQL, OOP, RAP, CDS views, EML statements, ABAP Cloud, strings, dynamic programming, RTTI/RTTC, field symbols, data references, exceptions, unit testing.