In our first sap 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.
1. Go to Gateway Service builder SEGW and expand the Service Implementation node of the service.
2. Under this node you will find five methods for each Entity Set.
Create – Includes the business logic to create data in the back-end system.
Delete – to delete the data from the back-end system.
GetEntity(Read) – to read the single record details from back-end system.
GetEntitySet(Query) – to read the list of data from the back-end system
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 sale-ale settingss orders from the back-end system we should write the abap code in GetEntitySet (Query) method. To read the single sale-ale settingss 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 sale-ale settingss orders from the back-end system. To do so right click on GetEntitySet(Query) → Go to ABAP Workbench.
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 find the method SALESORDERSET_GET_ENTITYSET to write the code.
6. Select the method SALESORDERSET_GET_ENTITYSET method and click on redefine button on the top.
7. You will find some commented code in the method when you redefine ignore that and write the below code to fetch the sale-ale settingss order using BAPI.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
DATA: ls_max_rows TYPE bapi_epm_max_rows, lt_sale-ale settingssorder TYPE TABLE OF bapi_epm_so_header, ls_sale-ale settingssorder TYPE bapi_epm_so_header, ls_entityset TYPE zcl_zdemo_gw_srv_mpc=>ts_sale-ale settingssorder. ls_max_rows-bapimaxrow = 20. CALL FUNCTION 'BAPI_EPM_SO_GET_LIST' EXPORTING max_rows = ls_max_rows TABLES soheaderdata = lt_sale-ale settingssorder. IF lt_sale-ale settingssorder IS NOT INITIAL. LOOP AT lt_sale-ale settingssorder INTO ls_sale-ale settingssorder. MOVE-CORRESPONDING ls_sale-ale settingssorder TO ls_entityset. APPEND ls_entityset TO et_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