ERPClimb logoERPClimb
OData Gateway
Architect / Cross-trackintermediate 8 min read

OData Gateway Part 6: GET_ENTITY and Key Handling

Preview · a free account unlocks the full lesson

Key takeaway

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 sections

Visual overview

OData Gateway Part 6: GET_ENTITY and Key Handling — learning sheetFlow: Redefine SALESORDERSET_GET_ENTITY → Read the key, apply ALPHA conversion, SELECT SINGLE → Raise resource_not_found when sy-subrc <> 0 → Add AUTHORITY-CHECK on V_VBAK_VKO. Key ideas: KEY INPUT; CONVERSIONS; READ AND MAP; NOT FOUND AND ERRORS. Watch out: Fiori object pages call GET_ENTITY after navigation from the list. A key that works in the list but not in GET_ENTITY is the most common "object page empty" bug.ERPClimb.com / ARCH / LESSON 6/10 / LEARNING SHEETOData Gateway Part 6: GET_ENTITY and Key Handling1 · HOW IT FLOWS1RedefineSALESORDERSET_GET_ENTITY2Read the key,apply ALPHAconversion…3Raiseresource_not_foundwhen sy-subrc…4AddAUTHORITY-CHECKon V_VBAK_VKO2 · KEY IDEAS EXPLAINEDKey InputURL: /SalesOrderSet('0000004711') — single key.Composite:/SalesOrderItemSet(SalesOrder='0000004711',SalesOrderItem='000010').ConversionsLeading zeros: CONVERSION_EXIT_ALPHA_INPUT forVBELN, KUNNR, LIFNR; material has its own exit(MATN1).Dates in keys: Edm.DateTime format in the URL(datetime'2026-01-31T00:00:00'); converted keysgive the ABAP date.Read And MapSELECT SINGLE with the full key.Map to er_entity (type from MPC).Not Found And ErrorsNot found → RAISE EXCEPTION TYPE/iwbep/cx_mgw_busi_exception with textidresource_not_found and entity_type → HTTP 404.Missing key → business error with a clear message(400).3 · REMEMBER · WATCH OUTRememberGET_ENTITY answers /EntitySet(key) — one record. Keys arrive init_key_tab as name/value pairs (strings) and via…SAP keys often have leading zeros (VBELN, KUNNR, MATNR); convert withCONVERSION_EXIT_ALPHA_INPUT before selecting, or the record is…If the entity does not exist, raise /IWBEP/CX_MGW_BUSI_EXCEPTION withtextid resource_not_found — the client receives HTTP 404, not an empty…!Watch outFiori object pages call GET_ENTITYafter navigation from the list. Akey that works in the list but notin GET_ENTITY is the most common"object page empty" bug.4 · IN A REAL PROJECTA Fiori list showed sales orders correctly, but the object page stayed empty for every order. The listreturned keys without leading zeros because a CONVERSION_EXIT_ALPHA_OUTPUT had been applied during mapping;GET_ENTITY then selected VBELN = '4711', which never exists in VBAK. The fix removed the output conversion…Original ERPClimb learning sheet • Verify against your SAP release and edition

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.

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

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.