In this post, you will learn how to test all operations from the SAP Gateway Client. The project for this is built in the earlier posts from this OData development series. The testing is briefly covered in the post, Building OData Services [4]: Register and Test OData Service, however, this is a more detailed explanation of CRUD-Q operations.

Here is what the project looks like.

1. Open SAP Gateway client

Option 1

Expand the Service Maintenance node and double-click on the item GW_HUB to see the Service Registration Details. Here, ensure that the highlighted row is selected. Then click on the SAP Gateway client.

Click Yes on the popup.

The SAP Gateway client will open with the service URI.

Option 2

Start transaction /n/IWFND/MAINT_SERVICE. Click on Filter.

Enter the Technical Service Name or part of the name with * and hit Enter.

Click on the required service, then click on SAP Gateway Client.

The SAP Gateway client will open with the service URI.

Option 3

Start transaction /n/IWFND/GW_CLIENT. The Gateway client will open with URI that was used in the earlier session.

Here, update the URI with /sap/opu/odata/sap/<service_name>/?$format=xml and you reach the same point as in options 1 and 2.

Once this screen is reached, explore the buttons Entity Sets and Add URI Option.

1. QUERY

Add Entity Set for Carrier in the URI using the button Entity Sets. Add format JSON using the Add URI Option button. Keep the HTTP method as GET and press Execute.

Request

Response

2. READ

Observe the Result from the Query operation. Each result set has the URI associated. Use this URI to get individual records i.e. READ operation.

Request

Response

3. ASSOCIATION

Observer the URI from READ or QUERY where the Association name is mentioned with _deferred status.

Use this URI, and add $format=json at the end.

Request

Response

In case you get any errors, add a unit for Distance Field and remove the field FLTIME as it gives conversion issues. Regenerate and try again.

The below options can also be tried in case you get cache-related issues after changes.

The CREATE, UPDATE and DELETE operations are implemented for CarrierSet only.

4. CREATE

First, perform a READ operation on the same entity set i.e. CarrierSet

Once the result is displayed, click on the Use as Request button to copy the response into the request payload.

The request part would appear as below.

Keep only the required JASON payload for the entity.

Now, make the below changes and Execute

  1. Change HTTP Method to POST
  2. Change Request URI to have only the entity set name
  3. Change the field values in the payload

Request

Response

SCARR table entry is created.

5. UPDATE

Notice that the CREATE payload did not have the URL field. So let us add a URL field in the service.

Use READ request to get details for Carrier ‘AI’. Copy the request using the button ‘Use as Request’.

Now, make the below changes and Execute

  1. Change HTTP Method to PUT
  2. Change Request URI to remove format option as the UPDATE operation does not return any result
  3. Change the field values in the payload to add the URL field value

Request

Response

Updated entry from SCARR

6. DELETE

Delete does not need a payload. Use URI similar to READ and HTTP method DELETE.

Request

Response

SCARR table entry is deleted.

This covers the basic CRUD-Q operations testing. More scenarios like Deep Inserts and multi-level associations will be covered in upcoming posts along with the testing.

Visit OData Development in SAP to explore all articles on OData.


If you like the content, please subscribe…

Join 4,016 other subscribers

Discovering ABAP YouTube Channel