0% found this document useful (0 votes)
42 views

CDS View Using Joins

The document discusses different types of joins that can be used in a CDS view, including inner joins, outer joins, and cross joins. It explains that inner and outer joins require an ON condition, while cross joins do not. It also provides examples of join syntax and describes how nested join expressions are evaluated.

Uploaded by

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

CDS View Using Joins

The document discusses different types of joins that can be used in a CDS view, including inner joins, outer joins, and cross joins. It explains that inner and outer joins require an ON condition, while cross joins do not. It also provides examples of join syntax and describes how nested join expressions are evaluated.

Uploaded by

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

CDS View Using Joins

In a join expression using INNER and OUTER, a join condition cond_expr must be specified after ON.


Special rules apply when this is specified. A join condition cannot be specified for a join expression
using CROSS.

Inner joins, outer joins, and cross joins are all possible:

 A join between two data sources using INNER JOIN or just JOIN selects all entries of the data
sources whose fields meet the ON condition.

 A join between two data sources using LEFT OUTER JOIN selects all entries on the left side. A
join between two data sources using RIGHT OUTER JOIN selects all entries on the right side.
Entries that meet the ON condition have the same content as in the inner join. In entries that do not
meet the ON condition, the elements on the right or left side have the null value that is set to the
type-dependent initial value when the CDS view is used in Open SQL.

 When two data sources are joined using CROSS JOIN, their cross product is produced. All entries
on the left side are combined with all entries on the right side. The number of rows in the results
set is the number of rows on the left side multiplied by the number of rows on the right side.

Nested join expressions are evaluated in the following order:

 In the case of inner and outer joins, by the arrangement of the ON conditions. From left to right, the
most adjacent ON conditions are assigned to each JOIN and this expression is parenthesized
implicitly. These implicit parentheses can be made explicit using actual parentheses, ( ). This is
optional.

 By default, cross joins are evaluated from left to right. The priority of the evaluation can be
influenced by parentheses ( ).

 If multiple cross joins are combined, the order of the evaluation is irrelevant. The result is always the
same and the number of rows is the product of the number of rows of all involved data sources.

 If cross joins are combined with inner and outer joins, the result can depend on the order of evaluation
or the parentheses.

Notes

 A WHERE condition for a SELECT statement with joins is applied to the results set created using the
joins.

 An inner join or a cross join between two individual data sources is commutative. If the left and
right side are switched, the result remains the same.

 Buffering is not recommended for a CDS view that contains an outer join. The results set can
contain null values, which means that Open SQL reads can behave differently to direct database
reads when the buffer is read, since null values in the buffer are transformed to initial values.

 The function coalesce can be used to prevent null values in the results set.

 A cross join behaves like an inner or outer join whose ON condition is always true. A cross join with
a WHERE condition has the same result as an inner join with an identical ON condition. Unlike the
inner join, in a cross join all data is read first before the condition is evaluated. In an inner join only
data that meets the ON condition is read.
 A cross join should only be used with extreme caution. Since it is not possible to specify
an ON condition, all data of all involved data sources is read. In the case of very large datasets, the
results set (whose number of rows is always the product of the number of all rows of both data
sources) can quickly become very large.

 On the database, a cross join of two client-specific data sources is defined internally as an inner
join, whose ON condition checks whether the client columns of the left and right side are equal. If
one side is not client-specific, the cross join is defined as specified.

 In nested join expressions, parentheses are recommended for making the code easier to read. In
the case of inner and outer joins, the parentheses can be specified wherever the ON conditions
specify parentheses implicitly.

 There is no limit on the number of join expressions in a SELECT statement of a CDS view in the
DDL, but there is an ATC check that produces a message once a specific number of expressions
is reached.

EXAMPLES :

@AbapCatalog.sqlViewName: 'Z1475CDSJOINS'

@AbapCatalog.compiler.compareFilter: true

@AccessControl.authorizationCheck: #CHECK

@EndUserText.label: 'joins'

define view Zjoins3 as select from vbak as _sheader

inner join vbap as _sitem on _sheader.vbeln = _sitem.vbeln

and _sheader.vbtyp = 'C'

inner join vbrp as _sbilling on _sheader.vbeln = _sbilling.aubel

left outer join kna1 as _customer on _sheader.kunnr = _customer.kunnr

key _sheader.vbeln as sales_order,

_sheader.vbtyp as order_type ,

_sitem.posnr as salesitem,

_sitem.matnr as material,

_sbilling.vbeln as billingdocument,

_customer.kunnr as customer

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy