When you define a CDS view entity, you can not only read from database tables, you can also use other CDS views as data source. Why would you build views on top of views?
The first reason is similar to the reasoning when structuring source code in classes and methods:
- Reuse existing functionality
- Avoid redundancies
- Support error analysis and maintenance
- The second argument is more technical. There are certain limitations when it comes to the nesting of SQL expressions and SQL functions within the same CDS view. Nested views are a common technique to overcome such restrictions.
- Probably the most important reason for nested views is the layering of your data model. In the ABAP RESTful Programming Model, for example, it is recommended that you define consumption views on top of data model views. While the data model views contain the general data model logic, the consumption views add consumption specific logic and metadata.