In a CDS projection view of a RAP BO, how do you handle associations: compositions, the to-parent association, plain associations, and fields you read through them? What breaks if you get it wrong?
Say your answer out loud first.
Practise another way
Every composition in the projection is redirected to the child's projection with redirected to composition child, and the child points back with redirected to parent. Plain associations, like customer or agency, I either expose unchanged or redirect to a projection of their target.
Fields read through an association, such as the agency name, are for display and texts. If I forget a redirect, the child disappears from the service or create-by-association stops working.
The three redirect forms (ABAP keyword documentation)
define root view entity ZC_Travel
provider contract transactional_query
as projection on ZR_Travel
{
key TravelUUID,
AgencyID,
_Agency.Name as AgencyName, // path field for display
_Booking : redirected to composition child ZC_Booking,
_Agency // plain association, target unchanged
}
define view entity ZC_Booking as projection on ZR_Booking
{
key BookingUUID,
TravelUUID,
_Travel : redirected to parent ZC_Travel
}
redirected to composition childkeeps the composition. The target must be the projection of the original child, cannot be a root, and must itself project exactly one to-parent association.redirected to parentkeeps the to-parent association.redirected topoints a plain association at a projection of its target. Used on a composition or to-parent association, it turns them into a simple association: the parent-child semantics are gone.- The original target must have a projection before you can redirect.
Plain associations. If the target is not projected (a released value help view, a currency view), expose the association unchanged, as SAP's /DMO/C_Travel_A_D does with _Agency and _Customer.
A transactional query can also define a new association, which is read-only, and fields from that new target cannot be added to the element list.
Path fields. _Agency.Name as AgencyName or _OverallStatus._Text.Text as OverallStatusText : localized exist for display and @ObjectModel.text.element. They are not part of the base BO's data, so the BO never writes them.
Symptoms when it goes wrong
| Mistake | What you see |
|---|---|
| Composition not redirected | Child missing from the service; use association _Booking { create; } in the projection BDEF fails |
Composition redirected with plain redirected to |
Navigation works, but no create-by-association or parent-child behavior |
| Draft BO, association not draft-enabled | Activation error "projected association ... is not draft enabled": add with draft to the association in the BDEF |
| Path field on a to-many association | Duplicate rows in the list |
Newer syntax. Recent keyword documentation also shows redefine association _child redirected to composition child ... above the element list; read it as the same redirect.
Writes all three redirect forms correctly, knows that plain redirect drops composition semantics, and links each mistake to a visible symptom in the service or BDEF.
Copies associations from the base view without redirecting and cannot explain why the child table or its Create button vanished.
Redirecting a composition with plain 'redirected to'. It activates, but the association is now simple, so create-by-association and the parent-child behavior are gone.
- Why must the child projection project its to-parent association before the parent can redirect the composition?
- When would you expose an association unchanged instead of redirecting it?
- How do you show a text for a code field in the projection?
5 official pages and 1 technical reference. Confidence: high. Checked 2 Dec 2026.
- Official page Backs the answer.
- Official page Backs the answer.
- Official page Backs the answer.
- Official page Backs the answer.
- Official page Backs the answer.
- Technical reference Backs the answer.