In modern web and mobile applications, interacting with backend systems via RESTful APIs is standard practice. SAP Gateway uses the OData protocol, which defines a set of standard HTTP methods—GET, POST, PUT, DELETE—to perform operations on data. Understanding how to handle these requests effectively in SAP Gateway is essential for building robust and responsive services.
This article explains the role of each HTTP method in SAP Gateway and how to implement their handling in your OData services.
| HTTP Method | Operation | Purpose |
|---|---|---|
| GET | Read | Retrieve data from the backend |
| POST | Create | Add new data records |
| PUT | Update / Replace | Modify existing data records |
| DELETE | Delete | Remove existing data records |
Each method corresponds to specific CRUD (Create, Read, Update, Delete) operations, forming the backbone of SAP Gateway OData services.
GET is used to fetch data from SAP systems. It comes in two flavors:
Implementation Tips:
GET_ENTITYSET and GET_ENTITY methods in the Data Provider Class (DPC_EXT).$filter, $select, and $orderby for flexible data retrieval.POST creates new data records in the backend.
Implementation Tips:
CREATE_ENTITY method in DPC_EXT.PUT updates or replaces an existing entity completely.
Implementation Tips:
UPDATE_ENTITY method in DPC_EXT.Note: For partial updates, SAP Gateway supports PATCH as well, but that is beyond the scope of this article.
DELETE removes an entity from the backend.
Implementation Tips:
DELETE_ENTITY method in DPC_EXT.METHOD zcl_my_service_dpc_ext->get_entity.
DATA: ls_entity TYPE zmy_entity.
" Read entity key from URI parameters
SELECT SINGLE * FROM zmy_table INTO ls_entity WHERE id = iv_entity_key.
IF sy-subrc <> 0.
RAISE EXCEPTION TYPE /iwbep/cx_mgw_busi_exception
EXPORTING textid = /iwbep/cx_mgw_busi_exception=>entity_not_found.
ENDIF.
" Map database structure to entity
er_entity = ls_entity.
ENDMETHOD.
Handling GET, POST, PUT, and DELETE requests is fundamental to creating fully functional SAP Gateway OData services. By implementing these HTTP methods correctly, you can provide reliable CRUD operations that power modern applications connecting to SAP systems.
Mastering these concepts paves the way for building scalable, secure, and maintainable integrations that leverage SAP’s rich business data and logic.