Describe a relationship once, then let a consumer navigate it

Orders refer to carriers by code. A CDS association models that relationship in the view definition and can be exposed for consumers to navigate when needed.

association [0..1] to zcarrier as _Carrier
  on $projection.CarrierCode = _Carrier.carrier_code

The cardinality [0..1] says there may be no carrier or one carrier for an order. It must match actual data and business constraints. Declaring [0..1] when multiple carrier rows can match is not a harmless optimization; it misrepresents the relationship.

Expose the association in the projection when consumers should be able to navigate it:

_Carrier

Association or explicit join?

A join combines source fields in one query result. An association names a reusable relationship and supports path navigation in CDS/ABAP SQL. Associations may be instantiated as joins when consumed; they are not simply preloaded child objects. Use an explicit join for a one-off combination; use an association when the relationship is part of the reusable model.

Practice

Add the association, ON condition, and projection exposure. This DDL exercise checks fragments only; no CDS activation occurs here.

Sources

Version note: CDS association features and cardinality semantics depend on ABAP release; validate against the target feature table.

Developer practice · ABAP

Practice: associate orders with carriers

Declare a to-one association from each order to a carrier and expose the association in the projection.

Complete the task using the syntax and structure described above. Variable names can differ if you use them consistently. This browser checker checks structure only; it does not compile or run ABAP.

0 required structures detected · 0 checks