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: 
MortenWittrock
Active Contributor


August has come around and it's time for part five of this blog post series, where I interview SAP Cloud Integration practitioners, developers, architects and enthusiasts about their favourite feature of the platform. For this installment, I'm talking to a luminary of the SAP integration community and a frequent Featured Contributor here on the SAP Community site: shriprasad.bhat. Let's get the interview started!

Could you introduce yourself briefly, please?

My name is Sriprasad Shivaram Bhat and I am currently working as an Enterprise Integration Specialist at British Telecom. I started my contribution to the community in 2015, focusing on the SAP Cloud Integration topic. Most of my time in here goes towards answering questions and giving them solutions, which makes me happy. I also write blogs when I would like to go deeper on some topic.

Thank you! On to the central question of this blog post series: What’s your favourite SAP Cloud Integration feature?

I have multiple features on my list but let us consider Content Filter this time. It is one of the most useful features for working with XML data. In my early days of blogging, I wrote about this feature and that blog still holds true today for most of the use cases.

Why that particular feature?

The Content Filter step comes in very handy when you want to manipulate XML data. This step helps to perform various XML operations like filtering, sorting and using different XPath functions without writing JavaScript or Groovy scripts. SAP Cloud Integration’s Content Filter supports XPath 3.0, which enables us to write kind of small XSLT lookalike functions in Content Filter.

Here's an example: We want to filter out the full-time employees and then sort their records based on their employee ID. The input XML looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<Root>
<Record>
<employeeType>FTE</employeeType>
<emplID>1</emplID>
<emplName>C</emplName>
</Record>
<Record>
<employeeType>CE</employeeType>
<emplID>2</emplID>
<emplName>BB</emplName>
</Record>
<Record>
<employeeType>FTE</employeeType>
<emplID>3</emplID>
<emplName>B</emplName>
</Record>
<Record>
<employeeType>FTE</employeeType>
<emplID>5</emplID>
<emplName>A</emplName>
</Record>
</Root>

This can be solved with a single Content Filter expression:

sort(/Root/Record[employeeType = 'FTE'],(),function($Record) { $Record/emplID })

This is the output:
<Record>
<employeeType>FTE</employeeType>
<emplID>1</emplID>
<emplName>C</emplName>
</Record>
<Record>
<employeeType>FTE</employeeType>
<emplID>3</emplID>
<emplName>B</emplName>
</Record>
<Record>
<employeeType>FTE</employeeType>
<emplID>5</emplID>
<emplName>A</emplName>
</Record>

How do you see this feature evolving going forward?

Here are some additional options that I would like to see made available for Content Filter:

  • Support for other data types like JSON and plain text content.

  • An explicit option to add a root element (at the moment we need to have a Content Modifier after the Content Filter to do this).

  • Additional support for using properties and headers (currently it's limited to the contains operator).

  • Support for removing nodelists that match certain conditions. For example, in an SAP SuccessFactors Compound Employee response, remove some specific Employment Info records and return the rest of the XML as it is.


Thanks for joining this blog post series, Sriprasad - I appreciate it a lot!
2 Comments
NickSYYang
Active Participant

Morten,

You can use this technique to achieve below wish.

  • An explicit option to add a root element (at the moment we need to have a Content Modifier after the Content Filter to do this).

Step 1: Change value type to String in the filter step.

Step 2: Change XPath expression to below.
('<Root>', sort(/Root/Record[employeeType = 'FTE'],(),function($Record) { $Record/emplID }) => serialize(), '</Root>') => string-join()

Here I use serialize() to convert nodelist to string and then use string-join() to add root element to the string. The content of the body after fitler step will be a valid XML string for output or groovy script or graphic mapping to process. No need for adding content modifer step. Two steps into one. Nice and neat.

 

Regards,

Nick

Sriprasadsbhat
Active Contributor
Hello Nick,

Nice addition to above xpath and it saves addition one more step just to add root nodes while using XPATH  3.0 relative expressions, will add this additional part to my repo 🙂 .

But standard feature to add root node ( like how we have in converters ) would convince more developers to use this step( ease of use ) since in most of the use case developers don't use typical XPATH 3.0 syntax or  capabilities as it requires more expertise.

Cheers!

Regards,

Sriprasad S Bhat
Labels in this area