How Extended CDS view Works?
Extended CDS view works very similarly to Extension of Transparent Table. The CDS is extended in Eclipse IDE by writing some code. It’s very simple to understand the basics of CDS extension. So, Let’s extend a CDS:
Goto Eclipse > Right Click on Project > New > Other > Data Definition > Enter Package, Name(Starts with Y or Z) and Description > Next > Enter Package if required > Next > Define View(or Define View with Join/Define View with Association/Define View withParameters) > Finish > Create a Test Base View
Something like this:
If you need to extend a Standard CDS view, you need to skip above step. The standard view is equivalent to above-created custom CDS view.
Now to create an Extended view: Right Click on Project > New > Other > Data Definition > Enter Package, Name(Starts with Y or Z) and Description > Next > Enter Package if required > Next > Extend View > Finish > Create a Test View Extension
CDS view extension is created by extending Base view as in this example. The result of above extension can be seen by checking Data preview of First Base view where new fields are added.
Note: Fields are added to the base view. Try “Ctrl + Click” the corresponding “sqlViewName” of the Base view and it leads to the SE11 transaction where extension concept will be crystal clear that how it works!
It is clear that second CDS along with fields are simply appended to first CDS!
Now a brain twister! Is it possible to extend a CDS view more than once? Is it even possible?
The answer is YES! Another APPEND takes place on each extension.
In What Scenario, an Extended view should be used?
- When a standard CDS view needs the addition of new fields.
- When a standard CDS view needs a change of fields, a good idea can be: adding new changed fields by extending CDS.
- When a Custom CDS needs a change and original CDS can’t be altered for some reasons.