首页 > SAP > HANA > Deep Insert in SAP Netweaver Gateway
2019
08-27

Deep Insert in SAP Netweaver Gateway

Hello everyone, in this Netweaver Gateway tutorial we will learn how to use  Deep Insert in SAP netweaver gateway OData service. Before proceeding further we assume that you know how to build OData service in sap gateway. Access all SAP Netweaver Gateway tutorials here.Lets get started

1.What Deep Insert in SAP OData service does ?

Deep Insert is used to POST the nested structure of feed/collections to the back-end system.It is opposite to the $expand in which we GET the nested structure of collections. By implementing this you can reduce the no.of OData calls made to the SAP Netweaver Gateway server.Prerequisite, entity sets which are used should be associated. To know about Association in OData service click here.

2.Supported System Version

SAP NetWeaver Gateway Release-采购向厂商下P/O之后,必须透过一定权限经由主管对此张P/O做 release后才能收料 2.0 Support Package >=03

3.Business Example

Create a Sales Order header together with the items with in a single OData service call.

4.How to Implement Deep Insert in OData Service ?

The Deep Insert is implemented by using the method CREATE_DEEP_ENTITY.

Follow the below steps.

Prerequisite : You should create a OData service to support $expand which is explained in my earlier tutorials. Click here to access the tutorial.

1. After successful creation of OData service in SAP Netweaver Gateway system. Go to the DPC extension class and identity the method /IWBEP/IF_MGW_APPL_SRV_RUNTIME~CREATE_DEEP_ENTITY and redefine it.

2. Copy and paste the below code in the method.

3. Let us see what we have done in the above step

Check the Entity set name is same as the Entity set name for which we need to use Deep Insert.
Get the Sales Order Header and item data from the request using the method IO_DATA_PROVIDER->READ_ENTRY_DATA( ).
Populate the BAPI structures with the data above retrieved.
Call the BAPI BAPI_EPM_SO_CREATE to create the Sales Order with line items.
If their are any errors messages in BAPI Return, send them to the OData service response and RAISE an EXCEPTION.
If the BAPI ran successfully, get the Sales Order details using the BAPI BAPI_EPM_SO_GET_DETAIL and send them to the OData service response.

4. We are done with coding part. Lets test the service again in SAP Netweaver Gateway Client /IWFND/GW_CLIENT.Call the below OData service URI with HTTP GET, to get the data of any sale-ale settingss order using $expand you should see the below output.

/sap/opu/odata/sap/ZDEMO_GW_SRV_SRV/SalesOrderSet(‘500000017’)?$expand=ToOrdetItems

5. Now press the button Use as Request, which exists in the response section in SAP Netweaver Gateway client. All the data from the response will be copied to the request section.

6. In the HTTP Request section clear the Sales order number and line item numbers, as we are creating a new sale-ale settingss order using this data.

7. Now we are ready with data to send it to the SAP Netweaver Gateway server to create the sale-ale settingss order. Test the service by changing the HTTP Method to POST, and OData service URI to

/sap/opu/odata/sap/ZDEMO_GW_SRV_SRV/SalesOrderSet

8. New sale-ale settingss order will be created and data for the newly created sale-ale settingss order will be displayed in the HTTP Response section like below.

You have successfully created sale-ale settingss order with nested structures using the Deep Insert concept tin SAP Netweaver Gateway.

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

Thank you.

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