oData(Part2)- Read Operation

light

Read Operation with GET_ENTITY .

 

 

The post describes how to implement the data provider extension class for the READ operation. [ Check the link oData- Part1   to create the entity type, entity set and runtime artifatcs.]

The SCARR table entries.

2.jpg

We have the project. In the entity data model ‘Carrid’ is the only key.

12.jpg

Go to the data provider extension class- ZCL_ZSCARR_DEMO_DPC_EXT. Right click on it and choose Go to ABAP workbench.

1

Select  change mode. Select the method: SCARRS_GET_ENTITY and click on the redefine button.

2

Now when we request with the URL  

https://server address/sap/opu/odata/sap/ZSCARR_DEMO_SRV/Scarrs(‘AA’), the IT_KEY_TAB is filed with the key value pair and return as a structure ER_ENTITY.

 

3

Put the below code: 

    DATAlv_carrid TYPE scarrcarrid.
    CHECK it_key_tab IS NOT INITIAL.
    DATA(ls_keyit_key_tab[ ].
    lv_carrid ls_keyvalue.
    SELECT SINGLE FROM scarr INTO CORRESPONDING FIELDS OF er_entity
                    WHERE carrid lv_carrid

4

Activate the code and go back.

5

Go Back.

6

From the Service Implementation , choose Maintain.

7

Choose Call Browser.

27.jpg

Well, here we have the XML format.

 

8

Now we have to form the url to read details with the key ‘Carrid’.

https://server address/sap/opu/odata/sap/ZSCARR_DEMO_SRV/Scarrs(‘AA’)

9

https://server address/sap/opu/odata/sap/ZSCARR_DEMO_SRV/Scarrs(‘LH’)

10

To check the html format we can use the below url as

https://server address/sap/opu/odata/sap/ZSCARR_DEMO_SRV/Scarrs(‘LH’)?sap-ds-debug=true

11


 

Advertisements

One comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s