What difference would it make to use CDS View instead of table name in select query?

What difference would it make to use CDS View instead of table name in select query?


In our projects, possibly at the technology or functional user level we are shown data at the table level. In the developments we must evaluate what to use, depending on the scenarios, if we have the profile of analysts my suggestion is to make a data analysis and then decide whether to use table access or CDS View Entities/CDS VIEW, depending on which SAP S/4 system we work in.

CDS View Entities serve as building blocks for your application. They provide a framework for defining and consuming semantically rich data models. This means that you can use CDS, which is an enhancement to SQL, to structure your data as needed. In addition, you can use CDS to enrich your data with metadata through annotations.

CDS view entities support many features that simplify data modeling for the user. For example, users can use expressions to perform calculations and process strings or arithmetic functions. Associations are also possible and replace joins with simple path expressions. In addition, CDS view entities automatically make use of code offloading functionality, which means that all calculations are performed at the database layer (rather than at the application layer), resulting in faster data retrieval.

In terms of performance it can offer some improvements, depending on the specific scenario and usage. The advantage is that you can access all associations included in the CDS view. These associations are only built if you actually use them in your ABAP, FIORI, etc.

Both CDS views and standard SQL statements generate at the end the same SELECT statements at DB level.

Personally I have been able to build VDM from CDS views, very complex and with a very good performance, unlike if I want to obtain the same data through access to tables in individual form the performance was not good.

For example, if we talk about analytical applications and API. The VDM in SAP S/4HANA Cloud and SAP S/4HANA is represented by CDS views. The CDS views that make up the VDM follow consistent modeling and naming rules. They expose business data - stored in database tables - in a format that is based on business semantics and therefore easier to consume.


To search for CDS, we can use the TX SDDLAR

Resultado



Comparison of CDS DDIC-Based Views vs. CDS View Entities

The following table shows the difference between CDS view entities and CDS views:


Specific example : I_BUSINESSPARTNER


  1. Data Model: I_BUSINESSPARTNER is a CDS view, which means it represents a predefined virtual data model that may include joins, projections, and calculated fields. The view is designed to simplify and optimize data access. In contrast, BUT000 is a base table in the underlying database schema. The CDS view might have already incorporated some performance optimizations and aggregated data from multiple tables, resulting in a more efficient query execution plan.
  2. Indexing: The underlying tables may have different indexes. CDS views like I_BUSINESSPARTNER can define their own indexes or leverage existing indexes from the underlying tables to enhance performance. These indexes are designed to optimize common access patterns, such as filtering, sorting, and joining. Using I_BUSINESSPARTNER might benefit from such index optimizations.
  3. Query Complexity: If your query involves complex joins, filtering conditions, or aggregations, using I_BUSINESSPARTNER might simplify your SQL statement. The CDS view abstracts away the underlying table structure and provides a higher-level interface to access the data. This can make the query more readable, maintainable, and less error-prone.
  4. Data Abstraction: I_BUSINESSPARTNER might provide a more business-oriented and semantically meaningful representation of the data compared to the raw tables like BUT000. The view might handle data transformations, conversions, or calculations to present the data in a more intuitive format. This can be beneficial for developers and analysts working with the data.


However, it's essential to note that the performance gains can vary based on the specific use case, database configuration, data volume, and the way the CDS view is implemented. It's recommended to perform performance tests and benchmarks to evaluate the actual impact of using I_BUSINESSPARTNER versus directly querying the BUT000 table in your particular scenario.


In general, using a well-designed and optimized CDS view like I_BUSINESSPARTNER can be considered a good practice as it promotes encapsulation, abstraction, and separation of concerns. It also aligns with the concept of modularization and reusability in software development.

Apart from the use of the TX SDDLAR I share a link to the HELP where we can find all Virtual Data Model and CDS Views by line of business.


https://help.sap.com/docs/SAP_S4HANA_ON-PREMISE/ee6ff9b281d8448f96b4fe6c89f2bdc8/8573b810511948c8a99c0672abc159aa.html?locale=en-US


Héctor Hernandez

SAP BW 7.31/ BW 4 Hana

7 个月

I'll keep this in mind

回复

要查看或添加评论,请登录

Sergio Cannelli的更多文章

  • How to Build Fiori App using CPI integration API?

    How to Build Fiori App using CPI integration API?

    Building a Fiori app using SAP Cloud Platform Integration (CPI) integration APIs involves several steps, including…

    2 条评论
  • Overview

    Overview

    Intro SAP Fiori elements is a framework that comprises the most commonly used floorplan templates and is designed to:…

    1 条评论
  • CAP vs. RAP

    CAP vs. RAP

    In this publication I share clear points of view to be able to choose between these 2 programming models. SAP…

  • SAP Developer News

    SAP Developer News

    SAP CodeJams LATAM Wrap Up Request your own SAP CodeJam: https://sap.to/6054lNo2i ABAP CDS 2408 Release & External…

  • 11 ERP Trends for 2024 and Beyond....

    11 ERP Trends for 2024 and Beyond....

    This last time, I have been questioning myself. What is the future of SAP?.

    2 条评论
  • Quick Tip

    Quick Tip

    In our ABAP programs, performance problems are often reported to us. We begin to analyze TABLES accesses.

    10 条评论
  • SAP products: Name changes

    SAP products: Name changes

    I have been asked about three specific SAP products and their names, I am sharing a short post with a summary on this…

  • SAP BTP es igual a SAP SCP?

    SAP BTP es igual a SAP SCP?

    Muchos se preguntan qué es SAP BTP. ?Comparación con SCP?.

  • Vistas CDS basadas en diccionario y las nuevas Entity View

    Vistas CDS basadas en diccionario y las nuevas Entity View

    En esta publicación comparto el uso de ambas tecnologías y sus diferencias. ?Alguna vez has intentado desarrollar…

    1 条评论
  • Próximo SAP GUI 8.0

    Próximo SAP GUI 8.0

    Con la llegada de SAP GUI 8.0 en el primer cuatrimestre de 2023, comparto algunas notas importantes que recopile de…

社区洞察

其他会员也浏览了