首页 > SAP > ODATA > UPDATE data in Back-end using OData Service
2019
08-29

UPDATE data in Back-end using OData Service

All these SAP Netweaver Gateway tutorials you have read till now, only read the data from the back-end systems.

Activate or Deactivate SAP Netweaver Gateway
How to Connect SAP Gateway to Back-end Systems
Structure of OData Service
Model your first OData Service
Implement your first OData Service
Register your first OData Service
Test your first OData Service
Single record read of a OData Service
Header and item data in OData Service
Association and Navigation in OData Service

In contrast to the READ access, CREATE, UPDATE and DELETE methods are also available in the OData service to create,update and delete the data in back-end systems.Lets see how we can do that.In this tutorial we UPDATE the existing data in back-end systems.Lets look what data we are going to update.We have sale-ale settingss order#500000002 in table SNWD_SO with Currency Code = EUR, we are going to modify the Currency Code to INR.

1. Go back to service builder SEGW and Service Implementation → SalesOrderSet → Update → Right click → Go To ABAP Workbench.

2. Put the Data Provider Class(DPC) extension class in change mode and redefine the method SALESORDERSET_UPDATE_ENTITY(  ) by clicking on redefine button.

3. Before jumping in to code lets look at the signature of the method and understand what parameters we can use.In the signature two parameters are important, one is IT_KEY_TAB which contains the key field value to which we need to update the data like sale-ale settingss order number and other one is IO_DATA_PROVIDER which contains what data we need to update. In our case IT_KEY_TAB will have sale-ale settingss order number and IO_DATA_PROVIDER contains new currency code.

4. Write the below code in the SALESORDERSET_UPDATE_ENTITY( ) method.

5. Activate the Data Provider Class extension class(DPC_EXT). To test the service go to SAP Netweaver Gateway Client /IWFND/GW_CLIENT. First we need to perform the single read to get the HTTP response body and we will be using the same HTTP body to push back the request to server with new Currency Code.

Execute the below URI with GET HTTP method

/sap/opu/odata/SAP/ZSL_EPM_DEMO_SRV/SalesOrderSet(‘500000002’)

6. After getting the response click on Use As Request button to copy the HTTP body to the left panel.

7. Change the currency code to ‘INR” and switch the HTTP method to PUT and execute it.

8. After successful execution, you will receive a HTTP response as HTTP 204.

9. Go back to the table and check the data is updated with new currency code.

Congrats! You have successfully used the UPDATE operation in SAP Netweaver Gateway OData service. Please stay tuned for SAP OData tutorials. Leave a comment in the below comment section and let us know your feedback. Thank you.

最后编辑:
作者:yangsen
本站为个人博客网站,全由我个人维护,我从事SAP开发13年,其它ERP开发7年,基本都是零售行业。本站记录工作学习的过程, 有SAP相关询问专、兼职工作可随时联系我。 有网站相关的问题可直接在文章下方留言,或者联系我。 邮件:yan252@163.com给我。 QQ:415402519