In this part, we will discuss the Query operation and along with various query parameter exist in the OData.Basically, Query operation is for getting all the records, which is also known as Feed.
For each entity set, there is a method called <entityset name>_GET_ENTITYSET . in the previous part (part 4), we covered the GET_ENTITY method which is returning response as single records(in ABAP word it is just like a workarea or structure 😉 ) but for GET_ENTITYSET will return multi/single record in the form of a table.
To implement the logic, we need to redefine the GET_ENTITYSET method. as below screenshot
So let’s test the result. URI : /sap/opu/odata/SAP/ZXYZ_SAMPLE_ODATA_SRV/OrderrHeaderSet
Query Option / URI Option Let’s discuss various query options like $select, $filter, $top,$skip,$inlinecount, $count , $orderby etc. Before discussing all the query options. Let’s check how the URL component will look like in general
$select
URI : /sap/opu/odata/SAP/ZXYZ_SAMPLE_ODATA_SRV/OrderrHeaderSet?$select=Vbeln,Vkorg,Vtweg
Similarly, there is another query option called $format, which is used for formating the response that can be used along with this.
URI: /sap/opu/odata/SAP/ZXYZ_SAMPLE_ODATA_SRV/OrderrHeaderSet?$select=Vbeln,Vkorg,Vtweg&$format=json
$filter
Filter is used to filter the records – like where clause in the select statement. Unlike $select(handled by the framework), $filter is solely the programmer’s responsibility to handle the code in the DPC_EXT. Let’s take an example to suppose we need to get the selected list of Vbeln instead of all in the response, in that we need to use the $filter.
/sap/opu/odata/SAP/ZXYZ_SAMPLE_ODATA_SRV/OrderrHeaderSet?$filter=Vbeln eq ‘32316’ or Vbeln eq ‘18317’
this is just like select …. where Vbeln in (‘32316’,18317). In the GET_ENTITYSET method, there are few importing parameters useful for Filter like
Once you get the information in the DPC_EXT class then sky is the limit, you can formulate the logic accordingly. There are various options like dynamic select or range etc. Give a try 😉
$count
URI : /sap/opu/odata/SAP/ZXYZ_SAMPLE_ODATA_SRV/OrderrHeaderSet/$count
We will cover the $top, $skip, $inlinecount,$orderby in the upcoming blog.
Previous Part: Get Operation in OData Service – Part 4 – ABAP Skill
Next Part : Paging in OData Service ($top,$skip)- Part 6- ABAP Skill SAP
3 Comments
Get Operation in OData Service – Part 4 - ABAP Skill · July 14, 2021 at 7:35 am
[…] Next Blog: Query Operation(GET_ENTITYSET) in OData – Part 5-ABAP Skill […]
Paging in OData Service ($top,$skip)- Part 6- ABAP Skill SAP · July 18, 2021 at 7:30 am
[…] and skip are used for get_entityset method ( Part 5 for more details ). Before implementing the logic there is a concept called offset and up to rows […]
Create(Create_entity) Method in OData SAP-Part 7-ABAP Skill · July 22, 2021 at 2:11 pm
[…] our previous parts, we are dealing with sales header information (Part 5), in the same fashion, we will create new sales order in the system by using create_entity. And the […]