Professional Documents
Culture Documents
1 of 13 25/03/2022, 18:37
My CDS view self study tutorial – Part 5 how to create CDS view whic... https://blogs.sap.com/2016/03/19/my-cds-view-self-study-tutorial-part...
So far we have a working CDS view ready for us to create a UI5 application on
top of it via Smart Template in WebIDE within just a couple of minutes. Once
done, the UI5 application will display the data from our CDS view like below. For
step by step how to achieve this, please refer to this blog: Step by Step to create
CDS view through SmartTemplate + WebIDE .
1. A CDS view which contains two fields: spfli.connid and spfli.carrid. This view
acts as the root node of the corresponding OData service model from semantic
point of view. This view can support navigation from itself to the defined children
node.
2. A CDS view which acts as the navigation target from previously defined “root”
view. Besides the two fields from sflight.connid and sflight.carrid which
correspond to the root view, it has additional new field sflight.fldate.
2 of 13 25/03/2022, 18:37
My CDS view self study tutorial – Part 5 how to create CDS view whic... https://blogs.sap.com/2016/03/19/my-cds-view-self-study-tutorial-part...
3. A CDS view which exposes the two fields connid and carrid from root view
and the associated data from child view.
This view is called “consumption” view and used to published as OData service.
@AbapCatalog.sqlViewName: 'zspfliroot'
@AbapCatalog.compiler.compareFilter: true
@AccessControl.authorizationCheck: #CHECK
@EndUserText.label: 'root view'
define view Zspfli_Root as select from spfli
association [0..*] to Zsflight_Child as _Item on $projection.carrid
and $projection.connid = _Item
{
key spfli.connid,
key spfli.carrid,
@ObjectModel.association.type: #TO_COMPOSITION_CHILD
_Item
}
@AbapCatalog.sqlViewName: 'zsflightchild'
@AbapCatalog.compiler.compareFilter: true
@AccessControl.authorizationCheck: #CHECK
@EndUserText.label: 'child_view'
define view Zsflight_Child as select from sflight
association [1..1] to zspfli_root as _root
on $projection.connid = _root.connid
and $projection.carrid = _root.carrid
{
key sflight.carrid,
key sflight.connid,
key sflight.fldate,
@ObjectModel.association.type: [#TO_COMPOSITION_ROOT, #TO_COMPOSITI
_root
}
3 of 13 25/03/2022, 18:37
My CDS view self study tutorial – Part 5 how to create CDS view whic... https://blogs.sap.com/2016/03/19/my-cds-view-self-study-tutorial-part...
@AbapCatalog.sqlViewName: 'zflight_c'
@AbapCatalog.compiler.compareFilter: true
@AccessControl.authorizationCheck: #CHECK
@EndUserText.label: 'flight consumption view'
@OData.publish: true
@ObjectModel: {
type: #CONSUMPTION,
compositionRoot,
createEnabled,
deleteEnabled,
updateEnabled
}
define view Zflight_Com as select from Zspfli_Root {
key Zspfli_Root.carrid,
key Zspfli_Root.connid,
@ObjectModel.association.type: [#TO_COMPOSITION_CHILD]
Zspfli_Root._Item
}
Activate all of these three CDS views. Since the third consumption view has
annotation @OData.publish: true, once activated there will be an OData service
automatically generated:
The entityset Zflight_Com has type Zflight_ComType, which has the navigation
Property “to_Item”. Now we can test the navigation.
4 of 13 25/03/2022, 18:37
My CDS view self study tutorial – Part 5 how to create CDS view whic... https://blogs.sap.com/2016/03/19/my-cds-view-self-study-tutorial-part...
And in the response, we are told that the correct url for navigation from current
node to its child node is just to append the navigation property defined in
metadata, toItem, to the end of url, that is, /sap/opu/odata
/sap/ZFLIGHT_COM_CDS/Zflight_Com(connid=’0400′,carrid=’LH’)/to_Item .
5 of 13 25/03/2022, 18:37
My CDS view self study tutorial – Part 5 how to create CDS view whic... https://blogs.sap.com/2016/03/19/my-cds-view-self-study-tutorial-part...
6 of 13 25/03/2022, 18:37
My CDS view self study tutorial – Part 5 how to create CDS view whic... https://blogs.sap.com/2016/03/19/my-cds-view-self-study-tutorial-part...
7 of 13 25/03/2022, 18:37
My CDS view self study tutorial – Part 5 how to create CDS view whic... https://blogs.sap.com/2016/03/19/my-cds-view-self-study-tutorial-part...
8 of 13 25/03/2022, 18:37
My CDS view self study tutorial – Part 5 how to create CDS view whic... https://blogs.sap.com/2016/03/19/my-cds-view-self-study-tutorial-part...
9 of 13 25/03/2022, 18:37
My CDS view self study tutorial – Part 5 how to create CDS view whic... https://blogs.sap.com/2016/03/19/my-cds-view-self-study-tutorial-part...
10 of 13 25/03/2022, 18:37
My CDS view self study tutorial – Part 5 how to create CDS view whic... https://blogs.sap.com/2016/03/19/my-cds-view-self-study-tutorial-part...
11 of 13 25/03/2022, 18:37
My CDS view self study tutorial – Part 5 how to create CDS view whic... https://blogs.sap.com/2016/03/19/my-cds-view-self-study-tutorial-part...
12 of 13 25/03/2022, 18:37
My CDS view self study tutorial – Part 5 how to create CDS view whic... https://blogs.sap.com/2016/03/19/my-cds-view-self-study-tutorial-part...
13 of 13 25/03/2022, 18:37