Let the behavior definition state the allowed operations
The request model defines its fields; the behavior definition states which transactional operations a consumer may request. For a new, managed BO, RAP supplies the standard transactional buffer and default CRUD handling for enabled operations.
Declare the behavior boundary
managed implementation in class ZBP_R_PURCHASE_REQUEST unique;
strict ( 2 );
define behavior for ZR_PURCHASE_REQUEST alias Request
persistent table zpurchase_request
lock master
{
create;
update;
}
This simplified BDEF enables create and update, but not delete. persistent table and the entity alias must agree with the actual CDS model and persistence. Managed behavior does not mean “no business logic”: validations, determinations, authorization, actions, and other rules can still require implementation.
An unmanaged BO is a different design: the provider implements its transaction buffer and operations. Don’t choose unmanaged merely to avoid learning managed behavior. Check BDEF syntax and supported features for the target release.
Sources
- SAP Samples: RAP BDEF syntax and managed implementation
- ABAP Keyword Documentation: RAP behavior definitions
Developer practice · ABAP
Practice: expose allowed create and update operations
Write a managed behavior definition for the fictional request root with create and update enabled.
Complete the task using the syntax and structure described above. Variable names can differ if you use them consistently. This browser checker checks structure only; it does not compile or run ABAP.
0 required structures detected · 0 checks
Write your solution, then check its structure.
One possible solution
managed implementation in class ZBP_R_PURCHASE_REQUEST unique;
strict ( 2 );
define behavior for ZR_PURCHASE_REQUEST alias Request
persistent table zpurchase_request
lock master
{
create;
update;
}
Debug this code
In this existing behavior definition, the workflow must not allow request deletion. Find and remove the operation that violates the rule.
Edit the code, then check for the expected repair. This is a structure check, not an ABAP compiler.
Find the issue, repair it, and check your change.
Diagnosis and repair
Diagnosis: The BDEF enables delete, which exceeds the stated business permissions. Remove delete; and keep only create and update.
define behavior for ZR_PURCHASE_REQUEST alias Request
persistent table zpurchase_request
lock master
{
create;
update;
}