There are a couple of different CDS view entity types, which can be used in ABAP Cloud to define selections on database tables and other existing data definitions.
When we want to create a such data definitions, we have a various of options to choose from. Most of them are really just templates with extended definitions like associations or they are already obsolet due the deprecation of CDS DDIC-views.


view entity
The view entity is the base of all coming entities and is the successor of the normal define view definition. It allows you to simply use any database table or existing data definiton to select fields from it or doing direct calculations inside, casting fields or grouping results etc.
@AbapCatalog.viewEnhancementCategory: [#NONE]
@AccessControl.authorizationCheck: #NOT_REQUIRED
@EndUserText.label: 'Orders view'
@Metadata.ignorePropagatedAnnotations: true
@ObjectModel.usageType:{
serviceQuality: #X,
sizeCategory: #S,
dataClass: #MIXED
}
define view entity ZI_Orders as select from zorders
{
key id as Id,
name as Name,
orderDate as OrderDate,
shippingDate as ShippingDate
// ...
}
root view entity
With a root view entity, we can now define any view entity to be a possible business object (BO). This BO can later be used in SAP RESTful application programming and is mandatory when you want to create associations with
@AccessControl.authorizationCheck: #NOT_REQUIRED
@EndUserText.label: 'Orders root view'
define root view entity ZI_Orders as select from zorders
composition of ZI_Positions as _Positions
{
key id as Id,
name as Name,
_Positions // Make association public
}
view entity with To-Parent association
The view entity with to-parent association defines now the child of a root entity. In our cases from above with an order example, this could be the positions. This
@AccessControl.authorizationCheck: #NOT_REQUIRED
@EndUserText.label: 'Positions'
define view entity ZI_Positions as select from zpositions
association to parent ZI_Orders as _Order
on $projection.order = _Order.id
{
key order as OrderId,
pos as Position,
_Order // Make association public
}
Extensibility views
These views are basically views, which allows you to project or extend an exisiting view to add more fields or to just select those fields, which you really need in your application.
projection view
The project view is a simple tool to just fetch the necessary fields from any entity view and may also rename them again, but is not necessary.
@EndUserText.label: 'Projection from orders'
@AccessControl.authorizationCheck: #NOT_REQUIRED
define view entity ZP_Orders as projection on ZI_Orders
{
key Id,
Name
// ...
}
extend view
With an extend view entity or just extend view (since it is not obsolet), you can extend a field like you would do it with an append structure in a database table.
@AbapCatalog.sqlViewAppendName: 'ZZ_ORDERS_EXTENDED'
@EndUserText.label: 'Orders extended'
extend view ZE_ORDERS with ZI_Orders_DDIC
{
Status
}
To extend an existing view entity, we need of course to add the definition as follows:
extend view entity ZI_Orders with {
Status
}
Further views
There are of course also the other view, which I may want to cover over time.
- Abstract entities
- Custom entities
As well as special definitions like
- Table functions
- Parent child hierarchy
Leave a Reply