Skip to Content

Introduction

This document illustrates How to create OData Service using Service Builder Tool (SEGW). This tool is installed via IW_BEP component in backend system.

Follow the steps to create and configure OData Service.

1.       Login to Gateway System -> Go to transaction SEGW -> click on New Project

/wp-content/uploads/2013/06/1_226334.png

2.    Give Name and Description. Select ‘Generation Strategy’ as ‘Standard’ and save it as a local object.

/wp-content/uploads/2013/06/2_226335.png

3.       A new blank project will be created as below

/wp-content/uploads/2013/06/3_226336.png

4.    Right Click on the data model and Click on Import and choose DDIC Structure

/wp-content/uploads/2013/06/4_226337.png

5.    Select any existing ABAP Structure, provide object name, Mark at least one property as Key and click ‘Continue’

/wp-content/uploads/2013/06/5_226338.png

6.      It creates an entity ‘Request’. Expand node to navigate to various properties.

/wp-content/uploads/2013/06/6_226339.png

7.      Create ‘Entity Set’ as below

/wp-content/uploads/2013/06/7_226350.png

8.      Give Entity Set name as ‘Requests’, select Entity Type from F4 Help and click ‘Continue’

/wp-content/uploads/2013/06/8_226351.png

9.      Click on ‘Entity Sets’ and check the properties Creatable, Updatable and Deletable

/wp-content/uploads/2013/06/9_226383.png

10. Getaway Model will appear as below

/wp-content/uploads/2013/06/10_226384.png

11. Click on Generate Runtime Objects button, on the top menu. This will generate runtime artifacts for the OData Service

/wp-content/uploads/2013/06/11_226385.png

A dialog box will pop up with pre-defined class names and service names.  Click on OK.

/wp-content/uploads/2013/06/11_a_226386.png

Add these objects in Local Objects

/wp-content/uploads/2013/06/11_b_226387.png

12.  After generation, you should find the following objects getting added to your project, under Runtime Artifacts node.

/wp-content/uploads/2013/06/12_226388.png

13. The ZCL_ZTEST_MPC class has the generated definition of the OData Service. The additional code has to be written in ZCL_ZTEST_MPC_EXT class. Right click on ZCL_ZTEST_MPC_EXT and select on Workbench option.

/wp-content/uploads/2013/06/13_226389.png

14.  This will open Class ZCL_ZTEST_MPC_EXT in ABAP Workbench. Enter Change Mode, Select ‘Define’ method and click on ‘Redefine’

/wp-content/uploads/2013/06/14_226390.png

Enter Below code

data : lo_property type ref to /iwbep/if_mgw_odata_property,
       lo_entity_type
type ref to /iwbep/if_mgw_odata_entity_typ.

super->define( ).

lo_entity_type = model->get_entity_type( ‘ZsdmreqList’).
lo_entity_type->set_creatable( abap_true ).
lo_entity_type->set_updatable( abap_true ).
lo_entity_type->set_deletable( abap_true ).
lo_entity_type->set_addressable( abap_true ).
lo_property = lo_entity_type->get_property( iv_property_name =
‘Requestnumber’ ).
lo_property->set_filterable( abap_true ).

Save and Activate the Class.

15.  Right click on ZCL_ZTEST_DPC_EXT and select on Workbench option.

/wp-content/uploads/2013/06/15_226391.png

16.  This will open Class ZCL_ZTEST_DPC_EXT in ABAP Workbench. Enter Change Mode, Select ‘REQUESTS_GET_ENTITYSET’ method and click on ‘Redefine’

/wp-content/uploads/2013/06/16_226392.png

Enter below Code. Save and Activate.

  DATA: ls_request LIKE LINE OF et_entityset,
        lt_requests
TYPE STANDARD TABLE OF zsdmreq_list,
        ls_req
TYPE zsdmreq_list.

  SELECT * FROM zsdmreq_list_tab INTO TABLE lt_requests.

  LOOP AT lt_requests INTO ls_req.
   
CLEAR ls_request.
    ls_request-requestnumber = ls_req-requestnumber .
    ls_request-requestname = ls_req-requestname .
    ls_request-status = ls_req-status .
    ls_request-priority = ls_req-priority .
    ls_request-contactdetails = ls_req-contactdetails .
    ls_request-summary = ls_req-summary .
    ls_request-requestdesc = ls_req-requestdesc .
    ls_request-usercomments = ls_req-usercomments .
    ls_request-additionaldtls = ls_req-additionaldtls .
    ls_request-requestorid = ls_req-requestorid .

    APPEND ls_request TO et_entityset.
  ENDLOOP.

Save and Activate it.

17. Similarly, other methods can be implemented.

/wp-content/uploads/2013/06/17_226393.png

18. Register OData Service with Gateway system

Go to transaction /IWFND/MAINT_SERVICE. Service maintenance screen will be displayed. Click on add service to add a service from Backend system.

/wp-content/uploads/2013/06/18_226394.png

Give Backend System Alias and Technical Service name (in our case ZTEST_SRV) and press ‘Enter’

/wp-content/uploads/2013/06/18_a_226395.png

19. Click on Technical Service Name and provide package as $TMP

/wp-content/uploads/2013/06/19_226396.png

/wp-content/uploads/2013/06/19_a_226400.png

Click ‘Continue’ and you will get below successful message:

/wp-content/uploads/2013/06/19_b_226401.png

Click Back button and verify that the newly created service is added to the list.

20. Test OData Service

Select ‘ZTEST_SRV’ and click ‘Call Browser’. This will open Service definition in browser.

/wp-content/uploads/2013/06/20_226402.png

Reference(s)

1.  http://scn.sap.com/

https://sapui5.netweaver.ondemand.com/sdk/#content/Overview.html

To report this post you need to login first.

8 Comments

You must be Logged on to comment or reply to a post.

  1. Ron Sargeant

    Hi Gaurav,

    There is something wrong at step14. There should be no need to redefine the “define” method in MPC_EXT. There should be a ‘define_<entity_name>’  sub-method generated in the MPC for each entity, and ‘define’ calls these. What version of IWBEP is this installed with?

    You do not need to set any of the attributes in step 9 (they currently have no real impact on the model or data providers) and they should be set on a ‘by case’ basis anyway. If you do set them, they are added to the generated code that step 14 is carrying out.

    These settings may have more importance with SAPUI5 tools integration – “addressable” certainly does.

    Regards

    RS

    (0) 

Leave a Reply