Skip to main content

RAP development

Goal

Take a CDS root view all the way to a published OData V4 service. The RAP triplet is three objects that always travel together:

ZI_CUSTOMER (root view — provides the structure)
└── ZBP_I_CUSTOMER (BDEF — defines actions, fields, authorization)
└── ZUI_CUSTOMER (SRVD — exposes it as an external service)
└── ZUI_CUSTOMER_O4 (SRVB — binds SRVD to a protocol/version: OData V4)

Prerequisites

Steps

1. Convert the view into a root view (draft)

Edit the DDL to declare it as a root:

@AccessControl.authorizationCheck: #CHECK
@EndUserText.label: 'Customer (root)'
define root view entity ZI_CUSTOMER
as select from zt_customer
{
key customer_id as CustomerId,
name as Name
}
adt ddl write ZI_CUSTOMER zi_customer.ddls.asddls -t $TR --activate

2. Behavior Definition (BDEF)

adt bdef create ZBP_I_CUSTOMER "Behavior for ZI_CUSTOMER" ZMYPKG -t $TR

cat > zbp_i_customer.abdl <<'BDEF'
managed implementation in class zbp_i_customer unique;
strict ( 2 );

define behavior for ZI_CUSTOMER alias Customer
persistent table zt_customer
lock master
authorization master ( instance )
{
field ( readonly, numbering : managed ) CustomerId;
field ( mandatory ) Name;

create;
update;
delete;
}
BDEF

adt bdef write ZBP_I_CUSTOMER zbp_i_customer.abdl -t $TR --activate

3. Behavior implementation class (optional for managed)

A managed BDEF auto-generates handler shells for validation / determination if you don't provide zbp_i_customer. Create one only if you need custom logic — see Object lifecycle for adt class create.

4. Service Definition (SRVD)

adt srvd create ZUI_CUSTOMER "Customer UI service" ZMYPKG -t $TR

cat > zui_customer.srvd.asrvd <<'SRVD'
@EndUserText.label: 'Customer UI service'
define service ZUI_CUSTOMER {
expose ZI_CUSTOMER as Customer;
}
SRVD

adt srvd write ZUI_CUSTOMER zui_customer.srvd.asrvd -t $TR --activate

5. Service Binding (SRVB) + publish

adt srvb create ZUI_CUSTOMER_O4 "OData V4 binding" ZMYPKG -t $TR

Bindings carry protocol + version metadata that isn't source — edit via checkout:

adt checkout srvb ZUI_CUSTOMER_O4 ./src
$EDITOR ./src/zui_customer_o4.srvb.xml # set <SERVICE_DEFINITION>ZUI_CUSTOMER</>, <BINDING_TYPE>ODATA</>, <BINDING_VERSION>V4</>
adt checkin ./src -p ZMYPKG -t $TR

Publish (≠ activate — publishing exposes the service on Gateway):

adt srvb publish ZUI_CUSTOMER_O4

Expected output:

Publishing ZUI_CUSTOMER_O4 ... published
Service URL: /sap/opu/odata4/sap/zui_customer_o4/srvd_f4/sap/zui_customer/0001/

6. Smoke-test

adt fetch /sap/opu/odata4/sap/zui_customer_o4/srvd_f4/sap/zui_customer/0001/\$metadata

Troubleshooting

ErrorCauseFix
RAP-020: Managed behaviour requires root viewView is not a root viewAdd root keyword in DDL and reactivate
RAP-124: Field Name not mandatory on persistent tablemandatory on a field declared optional on the tableEither allow the table field to be NOT NULL or remove mandatory
Service binding activation failed: SRVD is inactiveSRVD wasn't activated before SRVBActivate in order: DDL → BDEF → SRVD → SRVB
Gateway publish: /IWFND/MED_COCKPIT errorEmbedded Gateway not configuredAsk basis team to enable /IWFND/MAINT_SERVICE / run SICF activation for the OData node
Cannot unpublish binding — consumers activeRunning apps use the serviceUse adt srvb unpublish ZUI_CUSTOMER_O4 only during a window, or bump binding version

See also