rap
Help with RAP (RESTful ABAP Programming Model) development including behavior definitions, EML statements, managed and unmanaged BOs, draft handling, actions, validations, determinations, side effects, and business events. Use when users ask about RAP, BDEF, BDL, EML, behavior definitions, behavior pools, managed BO, unmanaged BO, draft-enabled BO, RAP actions, RAP validations, RAP determinations, RAP side effects, RAP business events, create/read/update/delete in RAP, or building transactional Fiori apps with ABAP Cloud. Triggers include "create a RAP BO", "write a behavior definition", "EML syntax", "managed vs unmanaged", "enable draft", "add an action", "add a validation", "RAP handler method", or "RAP saver class".
likweitan · 已有静态检查记录
安装与使用
运行命令前先阅读来源与依赖说明。复制命令不会自动安装或执行。
npx skills add likweitan/abap-skills --skill rap技能说明
name: rap description: Help with RAP (RESTful ABAP Programming Model) development including behavior definitions, EML statements, managed and unmanaged BOs, draft handling, actions, validations, determinations, side effects, and business events. Use when users ask about RAP, BDEF, BDL, EML, behavior definitions, behavior pools, managed BO, unmanaged BO, draft-enabled BO, RAP actions, RAP validations, RAP determinations, RAP side effects, RAP business events, create/read/update/delete in RAP, or building transactional Fiori apps with ABAP Cloud. Triggers include "create a RAP BO", "write a behavior definition", "EML syntax", "managed vs unmanaged", "enable draft", "add an action", "add a validation", "RAP handler method", or "RAP saver class".
RAP (RESTful ABAP Programming Model)
Guide for building transactional applications using the ABAP RESTful Application Programming Model (RAP) in ABAP Cloud.
Workflow
-
Determine the user's goal:
- Creating a new RAP BO from scratch
- Adding behavior (actions, validations, determinations) to an existing BO
- Writing EML statements to consume a RAP BO
- Troubleshooting RAP-related issues
- Understanding RAP concepts
-
Identify the scenario:
- Managed (greenfield) vs. unmanaged (brownfield)
- Draft-enabled or not
- Numbering concept: early/late, internal/external/managed
- Single entity or composition tree (root + children)
-
Guide implementation following the RAP layered architecture:
- Data modeling (database tables → CDS view entities)
- Behavior definition (BDEF using BDL)
- Behavior implementation (ABAP behavior pool)
- Business service exposure (service definition → service binding)
-
Provide code examples using correct BDL and EML syntax
RAP Architecture Layers
| 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 |
Implementation Types
Managed (Greenfield)
- Framework handles transactional buffer and standard CRUD operations automatically
- Only need custom code for non-standard operations (actions, validations, determinations)
- Automatic save handling (can be enhanced with
additional saveor replaced withunmanaged save)
managed implementation in class zbp_r_entity unique;
strict ( 2 );
Unmanaged (Brownfield)
- Developer provides transactional buffer and implements all operations
- Used when existing business logic needs to be embedded in RAP
unmanaged implementation in class zbp_r_entity unique;
strict ( 2 );
Behavior Definition (BDL) Quick Reference
Complete BDEF Structure
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 BDEF
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;
}
Key BDL Elements
| Element | Syntax
阅读完整来源 ↗