Dear All,
I am writing this blog to address the requirement where we need to Retrieve a value from the HTTP end point URL and use it OData request-reply or anywhere.
In my scenario, I need to convert below OData services from ECC system to Rest API in SAP Cloud Platform Integration (CPI)
/sap/opu/odata/sap/ZMT_SCANREST_SRV_01/HandlingUnit?$filter=HandlingUnitExternalID eq '12345'&$format=json
So, I followed many blogs for this requirement but could not find a relevant article about how the filter condition value can be retrieved from the end point URL.
I am dividing this end-to-end implementation into 4 steps –
- SENDER HTTPS configuration
- Formation of OData Address in request reply
- Retrieving filter condition value from HTTP CPI end point and using it in Query options of processing tab in request reply
- XML to Json conversion and logging payload
STEP 1 - SENDER HTTPS configuration
Address: /getHandlingUnit/*
Here the * after /getHandlingUnit allows us to put HandlingUnit value in CPI endpoint URL like /getHandlingUnit/123451
STEP 2 - Formation of OData Address in request reply
http://nnn.nnn.nnn.nn:8001/sap/opu/odata/SAP/ZMT_SCANREST_SRV_01/
replace nnn.nnn.nnn.nn with ECC system IP Address, 8001 port and append /sap/opu/odata/SAP/ZMT_SCANREST_SRV_01/ after port
Proxy Type: On-Premise
Use basic authentication and give your credential name which was deployed for ECC system in Security Material
STEP 3 - Retrieving filter condition value from HTTP CPI end point and using it in Query options of processing tab in request-reply
Operation: QUERY (GET)
Step 1 will display the details that are using to connect ECC system
Proceed to Step 2 after checking all details. It will establish the connection to ECC system.
After connecting to ECC, Click on Select in Processing tab and select respective Entity and give select Levels to display all lower order hierarchy elements.
Select All Fields or check required Fields
Proceed to step 3 for Filter & Sorting. Select the primary key field in dropdown, select the filter operation. I selected Equal to retrieve the data for HandlingUnitExternalID = 12345
${header.CamelHttpPath} – Technically this came expression gives the HandlingUnitExternalID value from HTTP end point URL. You can view as below if you trigger the end point from Postman and enable trace for CPI integration.
STEP 4 - XML to Json conversion and logging payload
Use XML To JSON Converter to convert XML response to Json format.
Groovy Script to Log Payload
Interface will look like this After successful configuration all above steps.
Deploy this interface and copy HTTP end point from Manage Integration Content
Let’s do quick testing –
Triggered endpoint from Postman and got response in Json format.
Corresponding message in CPI Monitoring page.
Hope this blog can help to check for any similar kind of requirements in CPI.
There is additional requirement to create an API for calling this OData service from anywhere (like from Browser, mobile application, Postman.. etc). I will be sharing this API and its Policies setup in next article.
I’ll be happy to hear your feedback and know if it helped you
🙂
Thanks & Regards,
Siva Kumar K.