You are on page 1of 6

4/23/2017 sapnetweavergateway

Implement your rst OData Service in SAP


Netweaver Gateway
By Prakash

In our rstsap netweaver gateway how to guides we have modeled the OData service. In this
tutorial we are going to implement the service i.e. writing the actual business logic to pull the
data from the back-end system.

[adsenseyu2]

1. Go to Gateway Service builder SEGW and expand the Service Implementation node of the
service.

2. Under this node you will nd ve methods for each Entity Set.

http://www.saplearners.com/implementyourfirstodataserviceinsapnetweavergateway/ 1/6
4/23/2017 sapnetweavergateway

1. Create Includes the business logic to create data in the back-end system.
2. Delete to delete the data from the back-end system.
3. GetEntity(Read) to read the single record details from back-end system.
4. GetEntitySet(Query) to read the list of data from the back-end system
5. Update- to update the data into back-end system.

Example: The service we are going to implement is Sales Order related. So to get the list of
sales orders from the back-end system we should write the abap code in GetEntitySet (Query)
method. To read the single sales order details we should write the abap code in GetEntity
(Read) method.

3. First we are going to implement the method GetEntitySet (Query) method to get the list of
sales orders from the back-end system. To do so right click on GetEntitySet(Query) Go to
ABAP Workbench.

http://www.saplearners.com/implementyourfirstodataserviceinsapnetweavergateway/ 2/6
4/23/2017 sapnetweavergateway

4. As we are going to implement the method ignore the popup and click on continue

5. You will be navigated to DPC_EXT class and nd the method


SALESORDERSET_GET_ENTITYSET to write the code.

http://www.saplearners.com/implementyourfirstodataserviceinsapnetweavergateway/ 3/6
4/23/2017 sapnetweavergateway

6. Select the method SALESORDERSET_GET_ENTITYSET method and click on redene button


on the top.

http://www.saplearners.com/implementyourfirstodataserviceinsapnetweavergateway/ 4/6
4/23/2017 sapnetweavergateway

7. You will nd some commented code in the method when you redene ignore that and write
the below code to fetch the sales order using BAPI.

DATA:ls_max_rowsTYPEbapi_epm_max_rows,
lt_salesorderTYPETABLEOFbapi_epm_so_header,
ls_salesorderTYPEbapi_epm_so_header,
ls_entitysetTYPEzcl_zdemo_gw_srv_mpc=>ts_salesorder.

ls_max_rowsbapimaxrow=20.
CALLFUNCTION'BAPI_EPM_SO_GET_LIST'
EXPORTING
max_rows=ls_max_rows
TABLES
soheaderdata=lt_salesorder.
IFlt_salesorderISNOTINITIAL.
LOOPATlt_salesorderINTOls_salesorder.
MOVECORRESPONDINGls_salesorderTOls_entityset.
APPENDls_entitysetTOet_entityset.
ENDLOOP.
ENDIF.

8. Save and activate the method SALESORDERSET_GET_ENTITYSET and then class


ZCL_SL_EPM_DEMO_DPC_EXT. Go back to the Service Builder.

This completes the service implementation of the service ZSL_EPM_DEMO. In our next tutorial
we will register and test the service in SAP Netweaver Gateway system

Stay tuned to us for more SAP Netweaver Gateway tutorials.Please feel free to comment and
let us know your feedback.

http://www.saplearners.com/implementyourfirstodataserviceinsapnetweavergateway/ 5/6
4/23/2017 sapnetweavergateway

Thank you.

Prakash

http://www.saplearners.com/implementyourfirstodataserviceinsapnetweavergateway/ 6/6

You might also like