OData Gateway Part 6: GET_ENTITY and Key Handling
Preview · a free account unlocks the full lesson
Implement single-entity reads in SEGW: read keys from it key tab or converted keys, apply ALPHA conversion, handle composite and date keys, return 404 for missing entities, check authorization, and avoid the typical key mismatches between $metadata, URL and database.
In this lessonShow sectionsHide sections
Visual overview
Explanation
Part 5 made the service reachable; now comes the single read that every object page uses. GET_ENTITY answers a request for /EntitySet(key) — a single record. Keys arrive in it_key_tab as name/value pairs where the values are strings, and also through io_tech_request_context->get_converted_keys, which gives the values already converted into the entity structure's own types. SAP keys often carry leading zeros — VBELN, KUNNR, MATNR — so they need to be converted with CONVERSION_EXIT_ALPHA_INPUT before being used in a SELECT, or the record simply won't be found.
In the URL, a single key looks like /SalesOrderSet('0000004711'), while a composite key looks like /SalesOrderItemSet(SalesOrder='0000004711',SalesOrderItem='000010'). it_key_tab gives you a table of name/value pairs using the external property names with string values, while io_tech_request_context->get_converted_keys( IMPORTING es_key_values = ls_entity ) gives you those same values already converted into the entity structure's real types.
A few conversion details matter here: leading zeros need CONVERSION_EXIT_ALPHA_INPUT for fields like VBELN, KUNNR, and LIFNR, while material numbers have their own conversion exit (MATN1); dates in keys arrive in Edm.DateTime format in the URL, such as datetime'2026-01-31T00:00:00', and the converted keys give you the equivalent ABAP date; and special characters in keys are URL-encoded by the client automatically.
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
Referenced SAP objects
Reviewed reference pages for the objects this page mentions.
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.