ABAP REST FUL
APPLICATION
P ROGRAMMING
B EHAVIOR DEFINITION
PARTH KOSARKAR
07/11/2024
managed;
The keyword managed means this is a managed scenario. Here, RAP Framework takes care of
CRUD operations. The other scenario is called Unmanaged where the developer has to write the
code to handle CRUD operations.
With the managed keyword, it is mandatory to specify the persistent tables for each entity.
Strict
applies additional syntax checks to behavior definitions, any outdated syntax can not be used and
implicit operations are required to be declared explicitly. There are two modes currently.
Strict mode version 1, specified using strict
Strict mode version 2, specified using strict(2)
Use the latest mode i.e. strict(2) in all your developments.
with draft;
with draft is used for enabling draft functionality. Along with this statement, we also need to specify
the draft tables for both entities.
The draft actions should also be mentioned.
The draft tables should not be created manually. Use quick-fix functionality to create the draft
tables. The draft table has all the fields from the persistent table and the field "%admin" which is
the addition for draft management.
define behavior for ZI_FE_Travel_001811 alias Travel
This statement specifies the implementation class where additional determinations and validation
can be implemented. In unmanaged scenario, the class implements all actions as well.
The mandatory addition unique defines that each operation can be implemented exactly once.
etag master LocalLastChangedAt;
Defines an entity as ETag master and assigns a field for change logging. The dependent entity can
use etag dependent by _Assoc as well.
field ( readonly ) TravelID;
This statement marks the readonly fields. All the fields mentioned after field ( readonly
) will become read-only on application.
All the field options available are as below.
field ( numbering : managed ) TravelUUID;
Defines managed internal numbering for the field. The field is automatically assigned
values upon creation of new record. This field has to be a primary key fields with
ABAP type raw(16) (UUID).
create; | update; | delete;
For root entity, we can have create, update and delete operations. For child or
dependent entities, we can only specify update and delete as create is dependent on
the parent or the root.
mapping for ZFE_ATRAV_001811
The mapping between entity properties and table fields is provided here. This is similar
to the CDS View Entity. We typically use CamelCase for entity properties for better
readability. In ABAP we use _ as separator as it is not case sensitive
association _Booking { create; with draft; }
Associations to child or parent are specified. We do not need to specify associations
for supporting entities which are added in the data model only to provide value helps,
names and descriptions.
The create operation for child entity i.e. booking is mentioned in this line.
determination CalculateTravelID on save { create; }
A determination modifies fields are properties at different points in time during the
runtime. Currently the options are on modify or on save. We can also specify trigger
conditions – { create; update; delete } i.e. when a specific operation is carried out or
on { field; } when value of a field is changed by create or update operation.
The determination is implemented in the class. Here we have empty methods created by the
generator.