ERPClimb logoERPClimb
Service Definitions
RAP / CDS / ODataadvanced 8 min read

Service Definitions Part 6: Exposing Multiple Entities and Navigation

Preview · a free account unlocks the full lesson

Key takeaway

Expose several entities in one service correctly: composition children, read-only related entities, value helps and text entities — and understand how navigation properties are created or dropped.

In this lessonShow sections

Visual overview

Service Definitions Part 6: Exposing Multiple Entities and Navigation — learning sheetIn one line: Expose several entities in one service correctly: composition children, read-only related entities, value helps and text entities — and understand how navigation properties are created or dropped.ERPClimb.com / RAP / LESSON 6/6 / LEARNING SHEETService Definitions Part 6: Exposing Multiple Entities andNavigation1 · IN ONE LINEExpose several entities in one service correctly: composition children, read-only relatedentities, value helps and text entities — and understand how navigation properties arecreated or dropped.2 · KEY IDEAS EXPLAINEDThe Navigation RuleYes → navigation property +NavigationPropertyBinding in $metadata; $expandworks.No → the navigation is removed from the service.Composition ChildrenExpose every child projection the app needs.In projections, redirect: _Item : redirected tocomposition child ZC_PurchReqItem; _Request :redirected to parent ZC_PurchReq.Read-Only Related EntitiesCreate a simple read-only projection (e.g.ZC_SupplierRO on I_Supplier) with no behavior.In ZC_PurchReq, redirect _Supplier to it (orexpose the association target directly).Value HelpsThe value-help entity must be accessible to theservice; RAP typically adds referenced value-helpentities automatically when possible, but exposing…Value-help views should be small, with a key, atext and @Search annotations for type-ahead.3 · DO · AVOIDBest practice!Common mistakeApply the navigation rule: expose source andtarget.Use lean read-only projections for relatedmaster data.Build dedicated, searchable value-help views.✕Forgetting to expose navigation targets, sonavigation disappears.✕Exposing large master-data projections insteadof lean read-only ones.✕Value helps pointing to entities the servicecannot reach.4 · IN A REAL PROJECTA purchase request app needed a supplier details link and a currency value help with type-ahead. The firstattempt exposed the full supplier master projection with all its associations, which inflated $metadata andexposed more data than needed. The team replaced it with a three-field read-only projection and a small…Original ERPClimb learning sheet • Verify against your SAP release and edition

Explanation

Parts 1 through 5 designed services around a root and its items. This final part covers services with more entities involved: related entities, value helps, and the rules governing navigation.

The navigation rule is simple but explains most "missing navigation" questions: for every association in an exposed projection, RAP checks whether the target is also exposed, either directly or as a redirected projection. If it is, a navigation property and a NavigationPropertyBinding entry appear in $metadata, and $expand works; if it isn't, the navigation is simply removed from the service.

Composition children need every child projection the app actually uses to be exposed, and in the projections, associations need to be redirected — _Item redirected to composition child ZC_PurchReqItem, and _Request redirected to parent ZC_PurchReq. With that in place, deep create — header and items in one request — works through the composition navigation.

Read-only related entities can be exposed too, for example when an object page should link to supplier details: a simple read-only projection, such as ZC_SupplierRO on I_Supplier, can be created with no behavior at all, and in ZC_PurchReq, _Supplier gets redirected to it (or the association target can be exposed directly). Once exposed in the service, the supplier becomes readable but not changeable — no BDEF is needed at all for a read-only entity like this.

Free account

Create a free account to keep reading

You have read the opening of this lesson. A free ERPClimb account unlocks the rest of it, every other lesson and topic, and your learning history, so you can pick up exactly where you stopped. No card needed.

  • Full explanation
  • Code example
  • Real project scenario
  • Common mistakes
  • Best practices
  • Interview angle

One tap with Google works too. Every topic keeps its first lesson open to everyone.

Keep exploring

Check before use: lesson examples are educational, not a guarantee of correctness for your SAP edition or release. Sample code has not been executed on your SAP system. Confirm API availability, syntax, authorizations and business impact in an approved development or test environment.