CDS View With Join Vs Associations
CDS View With Join Vs Associations
1.On Demand Joins: Associations act as on Demand joins, applying the join only
when a field from the right table is accessed.
2. Cardinality:
- `[0..1]` means many-to-one.
- `[0..2]` means many-to-two.
- `[0..*]` means many-to-many.
- `[1]` also means many-to-one.
3. Alias Naming: It's recommended to use an alias starting with an underscore for
the association table, like `_customer` in the example.
5. Filtering Limitation: Filters cannot be applied to the association table when the
cardinality is many-to-many `[0..*]`.
6. Join Type: By default, associations use a left outer join. To switch to an inner join,
•Path Expression: To access data from an association’s target, explicitly specify it when adding a field, like `_customer[inner].country`.
add a period(.) and an element name to the association name.
7. Path Expression: Use path expressions to filter specific fields. For example, if
•Example: If _customer links to the KNA1 table, a customer in the reading the text of the country table from association `_countrytext(t005T)`, filter
by English text using `_countrytext[spras = 'E'].LANDX AS COUNTRYNAME`.
Sales Order table VBAK can retrieve the country field from KNA1.
8. Field-Level Cardinality: Define cardinality at the field level with expressions like
•SQL Join: On the database level, this Path Expression results in a `_countrytext[1:spras = 'E'].LANDX AS COUNTRYNAME`.
join between the source and target tables, visible in the SQL
Create Statement. 9. Filter Merging: If `@AbapCatalog.compiler.compareFilter` is set to true,
multiple filters on the same field will be compared and merged into a single filter. If
set to false, merging does not occur.
VDM (Virtual Data Model) Components:
1. Interface Views:
- Basic Interface Views:
- Core Entity Views: Represent master data (e.g., Cost Centers).
- Text Views: Contain language-specific texts.
- Hierarchy Views: Show hierarchical structures.
- Characteristics: Free of redundancies, directly access database tables,
and can associate with other views.
2. Consumption Views:
Overview: - Built on Interface Views to meet specific application needs.
The Virtual Data Model (VDM) in SAP is built using ABAP CDS views to - Types:
offer a reusable, stable, and compatible platform for development. It - Pure Consumption Views: General views for data consumption.
enhances development efficiency, simplifies feature implementation, - Analytical Queries: Use the Analytical Engine for complex calculations
and reduces costs by providing a consistent and understandable like pivot tables and aggregations.
representation of business data.
Role of Interface Views:
Key Benefits: - Interface Views act as a bridge between database tables and consumption
1. Improved Performance: Efficient data access and processing. views, ensuring that the data model remains consistent and efficient for both
2. Extensibility: Allows for easy modification and extension. transactional and analytical applications.
3. Security & Privacy: Integrates with ABAP for reporting
authorizations.
4. Consistency: Ensures accurate and consistent calculations.
5. Cross-Application Views: Avoids redundant physical data through
joins.