Co-Authored: Ritesh K Kumaria, Shekhar Razdan
In continuation to the previous Post (The Semantically Rich Data Model – An ABAP based CDS Views example)
Annexure 3: How to Extend CDS views
CDS Extensions are ABAP dictionary object defined in the <DDL: Data Definition Language> of ABAP Core data services and is used to add fields of the entities used by a CDS View to a view without making modifications.
Take the template of Extend View and press Finish.
The extended fields (Origin_Airport & Disembarkation) are visible on the output by pressing F8 on demo_cds_original_view.
2. Extension using the $EXTENSION.*
Another way of extending the CDS view through use of $EXTENSION.*. This is in a way, similar to customizing includes in ABAP tables, where a place holder to add new fields is already provided in Standard SAP tables.
- If the CDS view is a union set created using union.
- If aggregate (MAX, MIN, AVG, SUM, and COUNT) expressions are used.
The below example is based on views organized based on Virtual Data Model (VDM) principles
Different types of Views:
- BASIC : Views that form the core data basis without data redundancies.
- COMPOSITE : Views that provide data derived and/or composed from the BASIC views.
- CONSUMPTION: Views that serve for specific application purposes and may be defined based upon public interface (For example, BASIC and COMPOSITE) views. The Consumption View is not shown in the above hierarchy.
Create an Append structure to DB tables and Extend the view ZCDS_DEMO_VIEW_2 and ZCDS_EXTENSION_VDM. For example an extension would be performed through the Append “OILVBAP” Field-OID_EXTBOL on VABP.
Views ZCDS_DEMO_VIEW_2 and ZCDS_EXTENSION_VDM have been extended as follows:
Extension for ZCDS_DEMO_VIEW_2
Extension for ZCDS_EXTENSION_VDM
Once the views have been extended and since the view ZCDS_EXTENSION_VDM is linked to ZCDS_DEMO_VIEW_2 via an Association the fields from Extension are added to the field list.
Another option could be at Extend the view ZCDS_EXTENSION_VDM and build another view on top of ZCDS_DEMO_VIEW_2 to include the field.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
5 | |
4 | |
3 | |
2 | |
2 | |
2 | |
1 | |
1 | |
1 | |
1 |