OData Gateway Part 8: CREATE_ENTITY, UPDATE_ENTITY and DELETE_ENTITY
Preview · a free account unlocks the full lesson
Implement write operations in SEGW: read the payload with read entry data, validate, lock, create/update/delete through BAPIs or Z-table logic, return the created entity, handle PUT vs PATCH/MERGE, HTTP status codes, CSRF tokens and commit rules.
In this lessonShow sectionsHide sections
Visual overview
Explanation
Parts 6 and 7 covered reading data; now the app needs to change it. The HTTP verbs map onto specific methods: POST maps to CREATE_ENTITY, PUT maps to UPDATE_ENTITY, PATCH/MERGE maps to PATCH_ENTITY (which by default reads the current entity via GET_ENTITY, merges in the new values, and calls UPDATE_ENTITY), and DELETE maps to DELETE_ENTITY. The request body is read with io_data_provider->read_entry_data( IMPORTING es_data = ls_entity ), while keys for update and delete come from it_key_tab.
In CREATE_ENTITY, you read the payload into the entity structure, validate mandatory fields and values, determine any numbers needed (via number range NUMBER_GET_NEXT or a BAPI's own output), create the record through a BAPI or a direct Z-table INSERT, and return the created entity in er_entity, resulting in HTTP 201 Created, including whatever keys were generated.
In UPDATE_ENTITY, the keys come from it_key_tab and the new values from read_entry_data. PUT means a full replacement — any property missing from the payload becomes initial — so a client wanting a partial change should use PATCH/MERGE instead. The method should check that the record exists (returning 404 if not), lock it, update it, and unlock it, with the response being 204 No Content.
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.