May 19

OData Basics – Part 2 (Read Operation)

Handling Read Operation in OData service:

We have one OData service available created as part of OData Basics – Part 1

Lets enhance the Data provider class [Note: All enhancements are done in extension class i.e., class name with suffix ‘EXT’. These EXT classes are sub classes of base class and can be enhanced by redefining methods]

2017-05-19 19_54_24-183.82.114.111_3333 - Remote Desktop Connection

Right click on Data provider extension class ZCL_ZRZ_SCARR_DEMO_DPC_EXT and navigate to workbench.

2017-05-19 19_55_05-183.82.114.111_3333 - Remote Desktop Connection

Redefine the SCARRSET_GET_ENTITY method

2017-05-19 19_56_16-183.82.114.111_3333 - Remote Desktop Connection

In that method, IT_KEY_TAB will bring the inputs

2017-05-19 19_58_51-183.82.114.111_3333 - Remote Desktop Connection

Using the key values, fetch the data from SCARR table and fill the exporting parameter ER_ENTITY. Write simple code shown in below screenshot:

2017-05-19 20_19_51-183.82.114.111_3333 - Remote Desktop Connection

Come back to Gateway service builder transaction after activating the changes in data provider class. Click maintain to test the changes..

2017-05-19 20_21_28-183.82.114.111_3333 - Remote Desktop Connection

Click “Call Browser”

2017-05-19 20_22_00-183.82.114.111_3333 - Remote Desktop Connection

Change the URL and pass input by referring the entity set as shown below and also find the results in the XML structure:

2017-05-19 20_23_11-183.82.114.111_3333 - Remote Desktop Connection

To debug and see how the data is being retrieved, pass additional parameter “sap-ds-debug=true”

2017-05-19 20_24_56-183.82.114.111_3333 - Remote Desktop Connection2017-05-19 20_26_01-183.82.114.111_3333 - Remote Desktop Connection

Try to verify Request/Response tabs also..

2017-05-19 20_27_31-183.82.114.111_3333 - Remote Desktop Connection