ABAP for Cloud Development
AS ABAP Release 914, ©Copyright 2024 SAP SE. All rights reserved.
ABAP - Keyword Documentation → ABAP RAP Business Objects → RAP - Behavior Definitions → RAP - BDL for Behavior Definitions → RAP - Projection Behavior Definitions → RAP - EntityBehaviorDefinition, Projection BDEF → RAP - EntityBehaviorBody, Projection BDEF → RAP - use, Projection and Interface BDEF →
RAP - augment
Syntax
... augment ...
Description
Optional addition for a reused standard operation that defines RAP BO augmentation for the operation in question. Augmentation is available for projection BDEFs only. With RAP BO augmentation, it is possible to modify incoming requests from a RAP BO consumer on the projection layer before data reaches the transactional buffer. For example, you can add data to requests reaching the projection BO before the request is passed to the handler method of the base BO. The operation augmentation must be implemented in the ABAP behavior pool of the projection BDEF in the RAP handler method FOR MODIFY
.
The following operations can be augmented:
It is not possible to set a field in augment which was already set for the original instance. The RAP runtime discards augment requests for fields that already have values. For example, values set in the original request cannot be changed. Only fields which are unset in the original request can be added.
It is not possible to set fields in augment that are defined as readonly
. Augment is handled like an external access and therefore, any attempt to access a readonly
field leads to a runtime error.
When the augmentation operation is executed, the original base instances have already been locked by the framework. If the augment contains new instances, then the runtime attempts to lock them. Instances for which locking fails are included in the FAILED
response of the projection request, and are removed from the base request.
Hint
It is possible to combine augment
and precheck
. If both the base BO and the projection BO define a precheck method, the execution order is as follows:
- Precheck on projection
- Augment on projection
- Precheck on base
This way, the request including the augmentation can be checked by the base precheck.
Further Information
- Development guide for the ABAP RESTful Application Programming Model, section Operation Augmentation.
Example
The following example shows a projection BDEF that demonstrates how to define and implement the operation augmentation for modify operations. The base BDEF is DEMO_RAP_MANAGED_ASSOC_ROOT
.
projection
implementation in class bp_demo_rap_proj_augment unique;
strict(2);
define behavior for DEMO_RAP_PROJ_AUGMENT alias _Parent
{
use create(augment);
use update(augment);
use delete;
use association _child { create(augment); }
field(modify) VirtualElement;
}
define behavior for DEMO_RAP_PROJ_AUGMENT_CHILD alias _Child
{
use update;
use delete;
use association _parent;
}
For the implementation in the ABAP behavior pool, see BP_DEMO_RAP_PROJ_AUGMENT======CCIMP
.
The ABAP class CL_DEMO_RAP_PROJ_AUGMENT
uses EML to access the RAP business object. It performs a create, an update, and a create-by-association operation. The augmentations are automatically performed, they add field values and / or add new entity instances.
Executable Example
The example listed above is displayed an explained in detail in topic RAP BDL - operation augmentation.