You should have done the following steps:
– 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.
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.
Naming convention: l - local scope t - table s - structure 01 method TRAVELAGENCYSET_GET_ENTITY. 02 03 DATA: ls_key_tab TYPE /iwbep/s_mgw_name_value_pair, 04 ls_entityset TYPE stravelag. 05 06 * key is TravelAgencySet(agency#) 07 READ TABLE it_key_tab INTO ls_key_tab INDEX 1. 08 09 SELECT SINGLE * FROM stravelag INTO ls_entityset WHERE agencynum = ls_key_tab-value. 10 11 er_entity = ls_entityset. 12 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.
– 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: