Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 
engswee
Active Contributor



Introduction


It is my pleasure to present to all you CPI enthusiasts the programming challenge we have for SAP CPI.

 

Let the Games Begin!


Background


In our integration scenario, we are integrating with the public Northwind OData service (https://services.odata.org/V2/Northwind/Northwind.svc/). We would like to provide a plain REST service to query the orders from the OData service.

Following is the CPI iFlow that is used in this scenario.


To achieve the querying mechanism, the HTTP query parameters from the sender needs to be converted into the corresponding OData filter criteria. The iFlow accepts dynamic key-value pairs used for querying which should be stored in the property filterCrit used in the OData receiver channel as shown below.



The Challenge


Develop a Groovy script to generate the OData filter criteria from the HTTP query parameters. Some of the key aspects of the script should be as follows:

  • Extract HTTP query parameter from header CamelHttpQuery, build the OData filter criteria and store it in property filterCrit. Below are some examples:-



















Input - HTTP Query Parameters Output - OData filter criteria 
ShipCountry=Sweden ShipCountry eq 'Sweden'
ShipCity=Stuttgart&ShipCountry=Germany ShipCity eq 'Stuttgart' and ShipCountry eq 'Germany'


  • Handle dynamically the different fields available in the Orders entity set

  • Handle different field types, e.g. numbers, String.

  • Each parameter can contain only single values, and the parameters cannot be repeated.

  • Only equality operator for the OData filter criteria is required.


 

 
3 Comments
Labels in this area