Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

ABAP CDS: Joins and Associations

former_member185171
Participant
0 Kudos
595

Hi All,

we are beginning development of CDS-views and trying to find our way in it.

We imported some CDS's for SLCM, and need some guidelines on the use of joins and associations:

as select distinct from PiqCds_OrgUnitPrograms ( p_idate : $parameters.p_date, p_lang : $parameters.p_lang) as org

...

inner join PiqCds_ProgramStudy ( p_idate : $parameters.p_date, p_lang : $parameters.p_lang )

as prog

on org.ProgramOfStudy = prog.ProgramOfStudy and org.ActivePlanVersion = prog.ActivePlanVersion

...

inner join dd07t

as text1

on text1.domname = 'PIQHS_STATE' and text1.ddlanguage = $parameters.p_lang and text1.domvalue_l = reg.prs_state

..

association [0..*] to PiqCdsAcademicYear as _AcademicYear on _AcademicYear.AcademicYear = reg.ayear

association [0..*] to PiqCdsAcademicSession as _AcademicSession on _AcademicSession.AcademicSession = reg.perid

...

Can anyone tell me why sometimes JOINs are used and sometimes ASSOCIATIONs?

Are there some guidelines when you should use one or the other?

Thanks for helping.

Kris

1 ACCEPTED SOLUTION

waldemar_schakiel
Participant
0 Kudos
248

Hello Kris,

associations should be prefered in CDS because defining associations is a more alegant way to code reusable joins. Associations can be adressed inside the view using path expressions and can be published for usage in other views.

Greetings

Waldemar

1 REPLY 1

waldemar_schakiel
Participant
0 Kudos
249

Hello Kris,

associations should be prefered in CDS because defining associations is a more alegant way to code reusable joins. Associations can be adressed inside the view using path expressions and can be published for usage in other views.

Greetings

Waldemar