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.
2. Provide the name of the entity type, ABAP structure name and Click on Next.
3. Pick the fields from the structure and Click Next
4. Choose Sales Order and Sales Order Item as key fields and click on Finish
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.
6. Go to the change mode of the DPC_EXT class and select the method ORDERITEMSSET_GET_ENTITY method and click on redefine.
7. Write the below code to retrieve the sales order item data for first 20 rows from the tables.
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.
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.
Click here to join our channel and stay updated with the latest tutorials and updates.