This video provides an overview of the relationship between CDS View and OData Service.
All SAP Fiori elements related annotations are translated to OData annotations. In this way, you can combine your business logic, OData service development, and annotation into one CDS view.
CDS as an OData Service
If a CDS view has the annotation "@Odata.Publish:true", an OData service is generated automatically in your back end system. The only thing you need to do is to activate it in your front end system.
Each OData service, no matter how it was developed, must be activated in transaction/IWFND/MAINT_SERVICE so that it can be queried externally.
The CDS view you are working on is transformed to an EntitySet with a name identical to the generated OData service.
All CDS views associated to this view are also transformed to an EntitySet. The association relationship is transformed to the Association and Navigation Property in the OData service.
Creating an OData Service by Referencing a CDS
In SAP Gateway Service Builder, you can reference an existing CDS view. Then, you can add associated CDS views selectively, even associations of associated views can be added to your OData Service.
You can then override MPC or DPC standard implementation to add write support and advanced OData features for the OData Service.
Relationship Between CDS Annotation and OData Annotation
In the figure below we see on the left side CDS UI annations @Ui.lineItem to create columns. @UI.identification represents an ordered collection of specific data fields that together with headerInfo identifies an entity to an end user. @UI.selectionField annotation allows filtering a list of data. This annotation is usually used in an initial page floorplan as filter bar. On the right side we see the transformation of the CDS annotations into OData annotations.
Like OData Annotations, CDS Annotations can apply on an EntitySet or a data field.
In most cases, there is a 1:1 relationship between an OData annotation term and a CDS annotation with a similar name.
CDS Annotations are grouped by target. Annotations with the same target stay together.
OData Annotations do not have a fixed position. It is usually grouped by terms.
When translated to an OData annotation, the sequence of CDS annotations belonging to one term is determined by a position property.