JOINs in CDS View

In ABAP CDS, Join between two data sources is allowed. Allowed joins are:-

  • Inner Join/Join
  • Left Outer Join
  • Right Outer Join

The post shows a simple Inner Join between data sources form SCARR & SPFLI table.

In HANA studio, open ABAP perspective. From Project explorer, right click on the package and choose New->Other ABAP Repository Object

ABAP CDS ON HANA-(5)テーブル結合ビュー-LMLPHP

Choose DDL Source & select Next

ABAP CDS ON HANA-(5)テーブル結合ビュー-LMLPHP

Provide a name & description & select finish

ABAP CDS ON HANA-(5)テーブル結合ビュー-LMLPHP

Provide aSQL View Name & code lines. Save & Activate.

ABAP CDS ON HANA-(5)テーブル結合ビュー-LMLPHP


@AbapCatalog.sqlViewName: ‘ZFLIGHT_JOIN’
@AbapCatalog.compiler.compareFilter: true
@AccessControl.authorizationCheck: #NOT_REQUIRED
@EndUserText.label: ‘Flight with Inner Join CDS View’
define view Zflight_Join_Vw
as select from spfli
join scarr
on spfli.carrid = scarr.carrid
{
key spfli.carrid,
key scarr.carrname,
key spfli.connid,
spfli.countryfr,
spfli.cityfrom,
spfli.airpfrom,
spfli.countryto,
spfli.cityto,
spfli.airpto
}

  


Execute it or by right click choose Data Preview.

ABAP CDS ON HANA-(5)テーブル結合ビュー-LMLPHP

Output:

ABAP CDS ON HANA-(5)テーブル結合ビュー-LMLPHP


05-11 22:11