This video is a tutorial on how to implement the “Order By” query option in OData. The presenter uses an existing OData service, Sales Order Service 02, to demonstrate the process. The tutorial is part of a series that progressively builds on the concepts covered in previous videos.
- Introduction to the “Order By” Query Option: The video begins with an introduction to the “Order By” query option in OData. This option allows users to sort the data returned by an OData service based on a specified field. The presenter demonstrates how to call this query option from the Uniform Resource Identifier (URI).
- Demonstration of Unsorted Data: The presenter shows the data returned by the OData service without any sorting applied. The data is fetched from the “Get Entity Set” method and displayed in an unsorted manner.
- Applying the “Order By” Query Option: The presenter then applies the “Order By” query option to the URI. He demonstrates how to sort the data by customer number in descending order. However, the data returned is still unsorted because no code has been implemented to handle the “Order By” query option.
- Implementing Code for the “Order By” Query Option: The presenter explains that to make the “Order By” query option work, some code needs to be implemented in the backend. He shows how to use the IO_TECH_REQUEST_CONTEXT object to get the details of the URI request, including the “Order By” details.
- Using a Utility Class for Dynamic Sorting: The presenter introduces a utility class that can be used for dynamic sorting. He explains how to use this class to sort the data based on the “Order By” query option. He demonstrates how to pass the “Order By” details and the data to be sorted to the utility class, which then returns the sorted data.
- Demonstration of Sorted Data: After implementing the code for the “Order By” query option, the presenter shows the sorted data returned by the OData service. He demonstrates how the data is now sorted by customer number in descending order and by sales order number in ascending order.
- Discussion on Different Ways to Implement Sorting: The presenter discusses different ways to implement sorting. He explains that the utility class is a convenient way to implement dynamic sorting, but there are other ways to achieve sorting, such as implementing it directly in the SELECT statement or at the database level if using HANA.