Technology Blogs by SAP
Learn how to extend and personalize SAP applications. Follow the SAP technology blog for insights into SAP BTP, ABAP, SAP Analytics Cloud, SAP HANA, and more.
cancel
Showing results for 
Search instead for 
Did you mean: 
tejesvi_dvr
Explorer
1,074

In odata - > soap $top and $skip operations are supported provided there is a web service operation which can return the In corresponding response. The operation must take an input parameter and return the Web Service response.

Steps from Design Time tool

  1. Create an OData Service Implementation Project
  2. Create an OData Model for getSalesOrder operation, which can have properties CustomerID, SalesOrderID, Note etc.

         

    3. Right click on odatasvc and choose Select data source

    4. Select the entity set and choose the query CRUD operation. Select the data source SOAP Service.

      

    5. Specify the wsdl file and choose the salesOrderInlineCount operation from the list of soap operations and click on finish

       

    6. Right click on Query and select Define Custom Code

    7. Select the script type as either javascript or groovy script

       

     8. Get the $top/$skip value from the uriInfo and form the corresponding input hash map/Soap Body to the web service as shown below. A hash map must be created in processRequestData function with key being top and value being $top value got from the UriInfo and in case of Skip A hash map must be created in processRequestData function with key being skipand value being $skip value got from the UriInfo

set the Hash Map to message body.


function processRequestData(message) {
  //Import statements
  importPackage(com.sap.gateway.ip.core.customdev.logging);
  importPackage(com.sap.gateway.ip.core.customdev.util);
  importPackage(org.apache.olingo.odata2.api.uri);
  importPackage(java.util);
  importPackage(com.sap.gateway.core.ip.component.commons);
  uriInfo = message.getHeaders().get("UriInfo");
    var startEntitySet = uriInfo.getStartEntitySet().getName();
    var top = "";
    var skip = "";
    if (uriInfo.getTop() != null)
      top = uriInfo.getTop();
    if (uriInfo.getSkip() != null)
      skip = uriInfo.getSkip();
    var keypredicate = "";
  parentMap = new LinkedHashMap();
  parentMap.put("CustID", "");
    parentMap.put("CustType", "");
    parentMap.put("top", top);
    parentMap.put("skip", skip);
    message.setBody(parentMap);
  
  return message;
}

If the odata request is https://localhost:8083/<Name SPACE>/<Project Name>;v=1/SalesOrderSet?$top=10

Then the soap request body looks like

<soapenv:Body>
   <web:getSalesOrders>
     <web:CustID></web:CustID>
     <web:CustType></web:CustType>
     <web:top>10</web:top>
     <web:skip></web:skip>
   </web:getSalesOrders>
</soapenv:Body>

if the odata request is https://localhost:8083/<Name SPACE>/<Project Name>;v=1/SalesOrderSet?$skip=2

Then the soap request body looks like

<soapenv:Body>
   <web:getSalesOrders>
     <web:CustID></web:CustID>
     <web:CustType></web:CustType>
     <web:top></web:top>
     <web:skip>2</web:skip>
   </web:getSalesOrders>
</soapenv:Body>

   9. Right click on Query and select Define Response Mapping, Enter the Description for the mapping and click on OK.

        

    10. Do the mapping as below

       

11. Right Click on Project and select Generate and Deploy Integration Content. This will deploy the bundle.

Now fire an OData Request https://localhost:8083/<Name SPACE>/<Project Name>;v=1/SalesOrderSet?$top=10 on the browser and response will give the list of top 10 sales Order entries.

Now fire an OData Request https://localhost:8083/<Name SPACE>/<Project Name>;v=1/SalesOrderSet?$skip=2 on the browser and response will give the list of Sales Order entries with 2 records Skipped.