Mentor SAP

Implementation of Create, Update, Delete (CUD) Operations

After having implemented the read and query methods for an entity set, we are now looking at how to implement change operations. If we want to create or change data, we have to retrieve this data from the incoming OData request. Use the read_entry_data method that is offered by import object reference io_data_provider. This is used to fetch the data that has been sent via a POST request.

 

Create Operation

The following types of Create operations are available:

 

When implementing the CREATE operation of an OData service you have to implement the <ENTITY>_CREATE_ENTITY method in the data provider extension class. Here you can retrieve the data with the following statement:

 

 

To create a proper HTTP request body needed for testing, you first have to perform a read request in the Gateway Client and use the “use as request” option. The server responds with an HTTP 201 response status code if the create operation was successful. The body of the HTTP response then contains the newly created entry.

 

Update Operation

The following types of Update operations are available:

 

When implementing the UPDATE operation of an OData service you have to implement the <ENTITY>_UPDATE_ENTITY method in the data provider extension class. Here you can retrieve the data with the following statement:

 

 

To create a proper HTTP request body needed for testing, you first have to perform a read request using the Gateway Client and use the “use as request” option. By default, the HTTP response is empty when a data entry has successfully been updated. If you want to retrieve the data of the updated entity, you must issue a separate read request. This can be done, for example, with a $batch request.

 

The server responds with an HTTP 204 response status code if the update operation was successful. The body of the HTTP response itself will be empty.

 

Delete Operation

The following types of Delete operations are available:

 

The key field(s) can be retrieved with the following coding: lt_keys = io_tech_request_context->get_keys( ).

 

The body of the HTTP request is empty. The server responds with an HTTP 204 response status code if the delete operation was successful. The body of the HTTP response is empty.