OData Gateway Part 3: $expand, Navigation, Deep Insert and $batch
Preview · a free account unlocks the full lesson
Handle related data in SEGW services: associations and navigation properties, navigation reads in GET ENTITYSET, $expand via GET EXPANDED ENTITY, deep insert of header with items via CREATE DEEP ENTITY, and $batch with changesets and commit rules.
In this lessonShow sectionsHide sections
Visual overview
Explanation
Part 1 returned a flat list, but real apps need header and item data together, which is where associations and navigation come in. An association such as SalesOrder (1) to SalesOrderItem (N), with a referential constraint of SalesOrder = SalesOrder, is set up under SEGW's Data Model → Associations, and it produces a navigation property — ToItems on SalesOrder — that the client can follow with a request like /SalesOrderSet('4711')/ToItems, which calls SALESORDERITEMSET_GET_ENTITYSET with the parent key arriving in it_key_tab or io_tech_request_context as the source keys.
$expand works similarly: /SalesOrderSet('4711')?$expand=ToItems returns the header together with its nested items. By default, the framework simply calls the child's GET_ENTITYSET once per parent, which is fine for a single parent but slow for a list — the classic N+1 problem. The fix is to redefine SALESORDERSET's own GET_EXPANDED_ENTITY (for a single read) or GET_EXPANDED_ENTITYSET (for a list), filling a deep structure directly and reporting the navigation as already handled in et_expanded_tech_clauses.
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
Interview questions on this topic
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.