Update an Entity using SAP OData

by | Jan 6, 2022 | ODATA

Home » SAP » ABAP » ODATA » Update an Entity using SAP OData

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.

Context

Update entity can be implemented by the redefining UPDATE_ENTITY method.

  1. Using PUT HTTP method.
  2. 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

  1. Open *DPC_EXT class artifact of OData and redefine *UPDATE_ENTITY method.
  2. Reimplement the method for the update.
    UPDATE_ENTITY method
  3. Activate the class and register the service.
  4. Execute and test the OData.
    1. Select Entity set
    2. Get the data to be updated using the GET request
    3. Click on Use as Request to copy the HTTP response to HTTP request which works as input.
      Execute and test the OData
    4. Change the field value Carname and URL in HTTP Request
    5. Select PUT option
    6. Add the key value to be updated in the request URL
    7. Execute the request
      Execute and test the OData PUT Request
    8. Status code 204 represents success
      PUT Request response
    9. Verify-in the table data is successfully updated.
      verify the updated data

Author

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Author