0% found this document useful (0 votes)
220 views4 pages

CDS View With Join Vs Associations

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
220 views4 pages

CDS View With Join Vs Associations

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Join Operation Combines data from multiple tables CDS View with JOIN

Parameters enable dynamic filtering at runtime, enhancing flexibility


and performance.

CDS View With Parameters


CDS View with Association

Open with Data


Preview

What’s an Association, Anyway?


•Definition: Associations express relationships between CDS entities.
•Lazy Joins/On Demand Joins: Associations are implemented as lazy/On Demand joins, meaning the join occurs only when a field from the associated
table is requested.
•Flexibility: They are more flexible than foreign key dependencies, allowing any CDS entity to link to any other, whereas foreign key dependencies link
specific tables.
•Components of an Association:
•Association Target: The CDS entity that the association targets (e.g., Kna1).
•Association Name: An identifier for the association, recommended to start with an underscore (e.g., _customer).
•Association Condition: Defines how the source and target entities are related, starting with the ON keyword. The condition usually compares
elements from both entities.
•Cardinality: Specifies the number of possible datasets in the target for a single dataset in the source(e.g.,[0..1])
•Exposure: To make an association visible, add its name to the element list of the CDS view.
Association: Path Expression Notable Points on 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.

4. Projection Table: The left table in an association is referred to as `$projection`.

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.

- Composite Interface Views:


- Combine Basic Views for complex reporting.
- Characteristics: Access Basic and other Composite views, introduce
some data redundancy, and are reusable.

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.

You might also like