Skip to Content
Technical Articles
Author's profile photo Eng Swee Yeoh

Education & Sharing Day 2020 – SAP CPI Programming Challenge

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.

 

 

Assigned Tags

      3 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Keshav Desai
      Keshav Desai

      Done! 🙂

       

       

      Author's profile photo Eng Swee Yeoh
      Eng Swee Yeoh
      Blog Post Author

      Great! Will check out your submission 🙂

      Author's profile photo Sunil Singh
      Sunil Singh

      Awaiting next challenge to be published.