Preface – This post is part of the SAP ABAP OData Tutorial series.
Many times, we come across a scenario where we want to update the data records, for example, we want to update the phone number or address.
This article describes the step-by-step procedure to implement and test update operations in SAP OData.
Table of Contents
Context
Update entity can be implemented by the redefining UPDATE_ENTITY method.
- Using PUT HTTP method.
- Using PATCH HTTP method.
Difference between PUT and PATCH HTTP method
- PUT: The request body is considered as the updated version of the original data stored in the database. When using PUT, we need to send the full payload in our request.
- PATCH: It is used for the partial modification of the resource. When using PATCH, we only send the data to be modified in the request body.
Procedure
- Open *DPC_EXT class artifact of OData and redefine *UPDATE_ENTITY method.
- Reimplement the method for the update.
- Activate the class and register the service.
- Execute and test the OData.
- Select Entity set
- Get the data to be updated using the GET request
- Click on Use as Request to copy the HTTP response to HTTP request which works as input.
- Change the field value Carname and URL in HTTP Request
- Select PUT option
- Add the key value to be updated in the request URL
- Execute the request
- Status code 204 represents success
- Verify-in the table data is successfully updated.
0 Comments