Skip to Content
Technical Articles

Part#5. CDS View Extension

SAP provides multiple standard CDS view related to each functional module and also during a project implementation you will create tons of CDS custom views.  Since the CDS views are just virtual data models, you will want to reuse the view created in one project or for one object to another project/object.  Let’s assume you created a CDS view with 5 fields on TABLE A and for another scenario in a different project you need 8 fields from the same TABLE A.  So instead of creating new CDS view from scratch, we can use the concept of CDS View extension and re-use the previous view we created and extend it with 3 new fields.

  1. Create a CDS view with Template ‘Extend View’

 

 

Below is the default view generated;

 

Now add the SQL view name and other properties;

  1. SQL View name: ZSQL_EXTEND_VIEW
  2. Let’s extend the view we created before: ZCDS_BASIC_VIEW. This could be a standard view as well.  Any view which you would like to extend with new fields.
  3. Hit CTRL + SPACE to see the fields which you would like to extend with. This will use the datasource/table used in the view we are extending i.e. table SFLIGHT in our case.

Add the fields you would like to extend and ‘Activate’ the view.

 

Hit F8 and check the output.  You can see that the 3 new fields are available in this view together with all other fields of the view we extended;

Hit F8 and check the output.  You can see that the 3 new fields are available in this view together with all other fields of the view we extended;

 

In summary, we looked at the re-usability concept in this blog post, which is very important to reduce the development effort and to follow the Best SAP Practices as well.  Instead of creating from scratch, it is highly important to know about SAP delivered standard CDS views to re-use them in your project to meet specific business requirements.

My next blog post will be about:

Part# 6. Parameters in a CDS view : Learn how to filter data in a CDS view

 

Follow me for upcoming blog posts: Sanjeev Kumar

Keep learning..

SK

 

Be the first to leave a comment
You must be Logged on to comment or reply to a post.