Skip to Content
Author's profile photo Kenichi Unnai

#1 – OData CRUD Crash Course – Read


You should have done the following steps:

#1 – OData CRUD Crash Course – Query

Step-by-Step Procedure

– Building Read operation

1. In SAP transaction SEGW, expand a project folder and open TravelAgencySet. Click on GetEntity (Read) and choose Go to ABAP Workbench. As the first implementation, you’ll see the popup.


2. Click on the *_DPC_EXT folder. The right pane should show the Class Interface shown in the next step.You’ll see the list of the methods. Scroll down – click and focus on the “…_GET_ENTITY” and press the Redefine icon.

Tip: Make sure if your editor is in edit mode with the /wp-content/uploads/2015/03/edit_674222.pngicon. Redefine icon is /wp-content/uploads/2015/03/redefine_674223.png.


3. Delete the commented out lines of code. You have an empty implementation.


4. If you click “Signature” text, you’ll see the in & out parameters of this method. We’ll implement so that it returns “ER_ENTITY” parameter.


Here’s implementation:

   Naming convention:
   l - local scope
   t - table
   s - structure

03   DATA: ls_key_tab   TYPE /iwbep/s_mgw_name_value_pair,
04         ls_entityset TYPE stravelag.
06 * key is TravelAgencySet(agency#)
07   READ TABLE it_key_tab INTO ls_key_tab INDEX 1.
09   SELECT SINGLE * FROM stravelag INTO ls_entityset WHERE agencynum = ls_key_tab-value.
11   er_entity = ls_entityset.
13 endmethod.

#03 declares a variable which holds the “key” value in the URL – such as ../TravelAgencySet(‘12345678‘). #07 picks up the key value. #09 selects an entity value with they key “agancynum”. #11 sets the returning value which will be sent in OData.

Make sure you activate it by /wp-content/uploads/2015/03/activate_675698.pngicon.

– Testing Read operation

1. Run the Query operation.


2. In a response body, choose an entity you want to read – find the OData URL in <id> tag.


3. Paste the URL and do the HTTP GET.


4. You should receive a response body content of the entity. The Read operation executed successfully!


What’s next? You can choose either of:

Create operation

Update operation

Delete operation

List of H2Gs

Assigned Tags

      1 Comment
      You must be Logged on to comment or reply to a post.
      Author's profile photo Former Member
      Former Member

      Hi Kenichi,

      thank you very much for this great tutorial.

      I tried to implement the get entity set method for the HRP1000 table. However, I'm getting the following error:

      "LS_KEY_TAB" cannot be a table or a reference, nor can it contain tables, references or strings

      I choose the field OBJID as a key.

      I didn't find anything about this issue, could you give me a hind?