Skip to content

ABAP Keyword Documentation →  ABAP Dictionary →  ABAP CDS in ABAP Dictionary →  ABAP CDS - Views →  ABAP CDS - DDL Statements →  ABAP CDS - DEFINE VIEW →  ABAP CDS - SELECT →  ABAP CDS - SELECT, data_source 


Other versions: 7.31 | 7.40 | 7.54


data_source ON cond_expr ...


Defines a join between two data sources of a CDS view in ABAP CDS. The code above is part of the syntax of a data source data_source and contains the recursive syntax of a data source data_source. Two data sources joined using JOIN create a join expression.

In every join expression, a join condition cond_expr must be specified after ON. When specified, special rules apply to this condition.

Both inner and outer joins are 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 a type-compliant initial value when the CDS view is used in Open SQL.

Join expressions can be enclosed in parentheses, ( ). This is optional. In recursive join expressions, the parentheses determine the order in which they are evaluated. If no parentheses are used, the most adjacent ON condition is assigned to each join from left to right and this expression is parenthesized implicitly.


A join condition must always be specified.


The following CDS view works in exactly the same way as the classic database view DEMO_SCARR_SPFLI. The program DEMO_CDS_JOIN uses SELECT to access the view.

@AbapCatalog.sqlViewName: 'DEMO_CDS_JOIN'
define view demo_cds_scarr_spfli
  (id, carrier, flight, departure, destination)
  as select from spfli
            join scarr on scarr.carrid = spfli.carrid
     { key spfli.carrid,
       key scarr.carrname,
       key spfli.connid,
       spfli.cityto }


The following non-parenthesized chaining of join expressions

... from tab1
            tab3 on =
                 on = ...

is parenthesized implicitly as follows:

... from tab1
        ( tab2
              tab3 on = ) on = ...

No elements from tab1 can be specified in the inner ON condition.