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: 
bhalchandraswcg
Contributor
3,120

Previous – Content Enricher | Index | Next – Claim Check


This week, we'll study a Message Transformation pattern known as Content Filter.

When do I use this pattern?


Content Filter pattern, as the name suggests, is used to filter out elements from the content of the message.

There are two main use cases of the Content Filter pattern:

  1. Removing out certain elements from a Node

  2. Removing out Nodes from a set of repeating Nodes based on a condition


I'll explore Use Case 1 in this blog. For example, removing out elements from Order payload that are not required by the receiver.

For Use Case 2, I refer you to alexander.bundschuh's blog on Content Filter pattern where he shows Use Case 2 in SAP Cloud Platform Integration and SAP Process Orchestration.

Content Filter in CPI


In CPI, we can use the Message Mapping component to remove unnecessary elements.

I'll get the Orders from Northwind service with Customer data and remove out some elements to demonstrate this pattern.

Integration Flow



Removing Elements from an Order


The integration flow is very simple. It starts immediately using Timer Event, gets the Orders from Northwind by applying the Command Message pattern, and filters out unnecessary elements using Message Mapping component.

Configuration of OData Receiver Adapter













































Tab Property Value
Connection Address https://services.odata.org/V2/Northwind/Northwind.svc
Connection Proxy Type Internet
Connection Authentication None
Connection CSRF Protected Unchecked
Processing Operation Details Query (GET)
Processing Resource Path Orders
Processing Query Options $expand=Customer

Content Filter


In the Content Filter, we filter out the Id fields from the Order node and the Id and Contact details from the Customer node.


Removed Elements from Order



Removed Elements from Customer



Execution


The result of using the content filter is that we are left with a succinct message.

Message before Content Filter


<Orders>
<Order>
<RequiredDate>1996-08-01T00:00:00.000</RequiredDate>
<ShipName>Vins et alcools Chevalier</ShipName>
<Customer>
<Customer>
<CompanyName>Vins et alcools Chevalier</CompanyName>
<Address>59 rue de l&apos;Abbaye</Address>
<Phone>26.47.15.10</Phone>
<Region/>
<PostalCode>51100</PostalCode>
<Country>France</Country>
<CustomerID>VINET</CustomerID>
<City>Reims</City>
<Fax>26.47.15.11</Fax>
<ContactName>Paul Henriot</ContactName>
<ContactTitle>Accounting Manager</ContactTitle>
</Customer>
</Customer>
<ShippedDate>1996-07-16T00:00:00.000</ShippedDate>
<ShipCity>Reims</ShipCity>
<CustomerID>VINET</CustomerID>
<ShipVia>3</ShipVia>
<ShipPostalCode>51100</ShipPostalCode>
<OrderID>10248</OrderID>
<OrderDate>1996-07-04T00:00:00.000</OrderDate>
<ShipRegion/>
<ShipAddress>59 rue de l&apos;Abbaye</ShipAddress>
<ShipCountry>France</ShipCountry>
<EmployeeID>5</EmployeeID>
<Freight>32.3800</Freight>
</Order>
...
</Orders>

Message after Content Filter


<Orders>
<Order>
<OrderID>10248</OrderID>
<OrderDate>1996-07-04T00:00:00.000</OrderDate>
<RequiredDate>1996-08-01T00:00:00.000</RequiredDate>
<ShippedDate>1996-07-16T00:00:00.000</ShippedDate>
<ShipVia>3</ShipVia>
<Freight>32.3800</Freight>
<ShipName>Vins et alcools Chevalier</ShipName>
<ShipAddress>59 rue de l&apos;Abbaye</ShipAddress>
<ShipCity>Reims</ShipCity>
<ShipRegion></ShipRegion>
<ShipPostalCode>51100</ShipPostalCode>
<ShipCountry>France</ShipCountry>
<Customer>
<Customer>
<CompanyName>Vins et alcools Chevalier</CompanyName>
<ContactName>Paul Henriot</ContactName>
<ContactTitle>Accounting Manager</ContactTitle>
</Customer>
</Customer>
</Order>
...
</Orders>

Conclusion


Content Filter pattern can be used to remove elements from a given node or remove certain nodes from a set of repeating nodes based on a condition. For both use cases, CPI has inbuilt components.

References/Further Readings



Hope this helps,
Bala

Previous – Content Enricher | Index | Next – Claim Check

4 Comments
Labels in this area