Header and Item data in SAP OData Service

4
24676

In our earlier SAP Netweaver Gateway OData tutorials part1, part2, part3 and part4 we tried to retrieve the Sales Order Header Information.

In this tutorial we will learn how to retrieve Item data and how to associate the Header Entity with Item Entity.

1. Create a new Entity Type for Sales Order Item information in service ZSL_EPM_DEMO. Right Click on Data Model → Import → DDIC Structure.

1

2. Provide the name of the entity type, ABAP structure name and Click on Next.

1

3. Pick the fields from the structure and Click Next

1

4. Choose Sales Order and Sales Order Item as key fields and click on Finish

1

5. This completes the creation of Entity Types. Regenerate the service to add the “OrderItems” Entity Type. Next step is to implement the methods of this entity type to pull the data.To implement the methods navigate to Service Implementation node and choose, expand the entity type “OrderItemsSet”.

Right click on GetEntitySet(Query) → Go to ABAP Workbench.

1

6. Go to the change mode of the DPC_EXT class and select the method ORDERITEMSSET_GET_ENTITY method and click on redefine.

1

7. Write the below code to retrieve the sales order item data for first 20 rows from the tables.

1

8. Save and activate the DPC_EXT method and class. This completes the implementation of the service to get the list of Sales Orders and their item data.Lets test the service to make sure that every thing is working properly till now.

9. Go to SAP Netweaver Gateway Client /IWFND/GW_CLIENT and enter service name with Entity Set name and execute the service.

12-16-2014 3-17-40 PM

10. In the result you can see the Sales Orders and Item data are retrieved in XML format. Till now we just retrieved the order and item data individually.

But now we want to retrieve the item data from entity set by giving the Order number in the service URI. To do, we need to understand two important concepts Association and Navigation in OData Service.

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

Thank you.

Comments are closed.