Skip to Content
0
Former Member
Feb 11, 2016 at 03:14 PM

Issue with Association in CDS view

1218 Views

Hi Friends,

Need some help with association in CDS view.

I am trying to convert the below join ddl using association. But getting error "Table b unknown or shadowed by an alias" at line number 47. Please help, what mistake I am making here.

@AbapCatalog.sqlViewName: 'ZTRM_BOOK'
@AbapCatalog.compiler.CompareFilter: true
@AccessControl.authorizationCheck: #CHECK
@EndUserText.label: 'Flight Booking Data'
define view Ztrm_Book_DDL as select from sbook as a
join spfli as b on
a.carrid = b.carrid and
                   a.connid = b.connid
join scarr as c on a.carrid = c.carrid
join sairport as d on b.airpfrom = d.id
join sairport as e on b.airpto = e.id
{
    a.carrid as carrid,
    a.connid as connid,
    fldate,
    bookid,
    passname,
    forcuram,
    b.airpfrom,
    d.name as airportfrom,
    cityfrom,
    countryfr,
    airpto,
    e.name as airportto,
    countryto,
    cityto,
    carrname,
    url,
    class,
    loccuram,
    loccurkey,
    order_date,
    agencynum    
}
---------------------------------------------------------------------------------------------------------------------------------------------------------
@AbapCatalog.sqlViewName: 'ZTRM_BOOK'
@AbapCatalog.compiler.CompareFilter: true
@AccessControl.authorizationCheck: #CHECK
@EndUserText.label: 'Flight Booking Data'
define view Ztrm_Book_DDL as select from sbook as a
association [1] to spfli as b
    on a.carrid = b.carrid and
       a.connid = b.connid
association [1] to scarr as c
on a.carrid = c.carrid      
association [1] to SAIRPORT as d
on b.airpfrom = d.id //Table b unknown or shadowed by an alias
association [1] to sairport as e
on b.airpto = e.id     
{
    a.carrid as carrid,
    a.connid as connid,
    fldate,
    bookid,
    passname,
    forcuram,
    b.airpfrom,
    d.name as airportfrom,
    cityfrom,
    countryfr,
    airpto,
    e.name as airportto,
    countryto,
    cityto,
    carrname,
    url,
    class,
    loccuram,
    loccurkey,
    order_date,
    agencynum
  //  _association_name // Make association public
  
}