Skip to Content
Author's profile photo Sujit Hemachandran

Blog 6: Splitting messages in Integration Flows

Hello Integrators!

 

In this blog, we shall look into the splitter pattern provided in SAP Cloud Platform Integration. The use of a splitter is quite clear from its name – to break out a composite message into a series of individual messages, each containing data related to one item.

 

How is Splitter supported in Integration Flows?

 

In SAP Cloud Platform Integration, a splitter is available as a Message Routing flowstep. When you configure a splitter flowstep, it can appear confusing at first. Lots of options!

 

Splitter_Options.JPG

 

Nevertheless, let us try to understand Iterating and General Splitter first.

A very cool way to understand the workings of the splitter is by configuring a integration flow like below (idea courtesy: HCI development team).

Integration_Flow.JPG

In the Content Modifier step, I insert the following payload in the Body. It is group of orders:

Orders_full.JPG

Each order has details in the following format.

Order_expanded.JPG

 

Now, let us see how the splitter works. In the first splitter, after the content modifier, we have configured a General splitter the following properties.

SP1.png

 

/wp-content/uploads/2015/01/output1_625826.png

 

The exclusive gateway step routes the message according to the ordernumber.

gateway.JPG

 

Let us go to the second splitter that has been configured as a Iterating splitter with expression type as Token.

/wp-content/uploads/2015/01/config_2_625829.png

This is how the output of the second splitter looks like. Notice that the root tags of the incoming payload is not retained and further, it has been grouped as per the number provided.

 

/wp-content/uploads/2015/01/output2_625830.png

Note: The Token splitter is mainly used for non-xml payload. I have just illustrated this example so that you can understand its working. Here “<item>” (including the angle brackets) form the “token”.

 

And if we configure the Iterating splitter with the expression type as XPath and the properties as below, we get the same output as the previous one. The only difference being there shall be the XML tag in the beginning of the output message <?xml version=”1.0″ encoding=”UTF-8″?>.

SP_3.JPG

 

The forth splitter is also a General splitter. But, I recommend that you configure the same so that you can see the difference with the Iterating splitter against the same message. The difference lies in the enveloping signature of the XML. Compare this output with the previous one.

GeneralSplitterOutput.JPG

 

Conclusion

 

You use the splitter flow step in SAP Cloud Platform Integration to break down a composite message. For XML payloads, you would use the general and iterative-xpath splitters. Iterative-token type is used for non-xml payloads. The other variants – IDOC and PKCS are used in specific scenarios. I shall cover those in another blog.

 

Best Regards,

Sujit

Assigned Tags

      12 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Misher Liu
      Misher Liu

      Hi Sujit, These series of blogs about dev in HCI are very very very useful. I am your big fan. Thanks a lot for sharing. Br Misher

      Author's profile photo Sujit Hemachandran
      Sujit Hemachandran
      Blog Post Author

      Thanks for your kind words, Misher!

      Author's profile photo Arpna Kaul
      Arpna Kaul

      Hi Sujit,

      I have a similar requirement like you showed. In the end, instead of generating separate output documents I want to combine in a single document. It is like I am executing in a loop i.e. one employee at a time based on their employee status and then I want to send a single document in the end. As employees are being executed 1 at a time therefore n number of documents are being created currently.

      What I understand is that we cannot use Gather after router so please help me with best possible solution.

       

      Thanks,

      Arpna

      Author's profile photo Casper Sloth Andersen
      Casper Sloth Andersen

      Hi Arpna,

       

      Not sure if it's relevant still, but for the benefit of others:

      You simply put the part where you do the routing into a subprocess.

      Note that if you want to discard records with routing, then this is not possible in a subprocess, since all records that go to an end event will be returned to the calling process. For this, you use a filter instead.

       

      Author's profile photo Ashish Saini
      Ashish Saini

      Hi Casper!

      Thanks for the great article.

      I have a situation similar to what Arpna described, the only difference being, I don't want to gather all the data from individual 'splits' into a single document.

      If I place a splitter and right after it I add a router, can I end each 'route' in its own individual 'end message' event?

      Another way of saying this is- is it okay if the payload splits into 1000 branches and each branch chooses a 'route' (based on some condition), and terminates within the route without ever consolidating with the other branches?

      (I should also point out that each 'route' needs to perform its own specific API calls. This will result in 1000 API calls for the 1000 branches coming from the splitter. Is this the right way to do it, or is there a better approach?)

      Thanks for reading, I'd appreciate any help I can get!

      -Ashish

      Author's profile photo Former Member
      Former Member

      Hi Arpna,

       

      I have same requirement like yours. Have you got any solutions about this scenario?

       

      Thanks and best regards

      Eric

      Author's profile photo Poornapragna TS
      Poornapragna TS

      Hi Sujit,

       

      When we use Iterating splitter, do we get to know the index of the item that we are iterating currently in the flow?

      Is there any index variable set by HCI so that we can use it?

       

      Thanks & Regards,

      Poornapragna

      Author's profile photo Former Member
      Former Member

      ${property.CamelSplitIndex}

      Check this

       

      Author's profile photo Former Member
      Former Member

      Hi Sujit ,

      Thanks for your sharing.

      is that  grouping field support to parameterized?

      Thanks ,

      Chris

      Author's profile photo Aananda Guru
      Aananda Guru

      Hi Sujit

      Im trying to use the inverse condition. I have a requirement to check if the data exists after payload gather. While I insert a Router element after gather, I'm getting a type conversion exception with [#document:null] Not sure what to do to have the data check after gather.

      I have explained my problem in the following link.

      https://answers.sap.com/questions/12664528/exception-while-using-router-after-gather-cpi.html

      Regards, Aanand.
      Author's profile photo Sudeep Menakuru
      Sudeep Menakuru

      Hi All,

      But when we use the General Splitter, the nodes which are in next element to the configured element are not resulting in the output. Example below.

      If we configure the Xpath to split on job_information, the compensation_information and PaymentInformationV3 is not coming out from the output of GeneralSplitter.

      I read in SAP blog that this is the functionality of General Splitter, which is not useful anymore as we need to map the target with compensation_information and PaymentInformationV3 nodes as well.

      Kindly suggest what can be done? Shall we ask SAP to introduce a splitter that can acheive the functionality that we are expecting?

      Author's profile photo Sudeep Menakuru
      Sudeep Menakuru
      <CompoundEmployee>
      	<id></id>
      	<person>
      		<action>NO CHANGE</action>
      		<personal_information>
      			<action>CHANGE</action>
      		</personal_information>
      		<employment_information>
      			<action>NO CHANGE</action>
      			<job_information>
      				<action>NO CHANGE</action>
      			</job_information>
      			<job_information>
      				<action>CHANGE</action>
      			</job_information>
      			<compensation_information>
      				<action>NO CHANGE</action>
      			</compensation_information>
      			<PaymentInformationV3>
      				<action>NO CHANGE</action>
      			</PaymentInformationV3>
      		</employment_information>
      		<national_id_card>
      			<action>NO CHANGE</action>
      		</national_id_card>
      	</person>
      </CompoundEmployee>