This blog covers an idea on how we can put CPI Aggregator to use for clubbing payloads having a similar value and creating separate files for them.

As an example, we can take Customer Master payloads being triggered from SAP to CPI. All these messages may have different company codes, but output needs to be created in such a way that, separate files need to be created for each unique company code viz. All payloads having Company Code=A will be present in a file, al payloads having Company Code=B will be present in another file and so on.

Requirement :

  • Flow : SAP S4 –> CPI –> 3rd party system
  • Source Message : IDOC (multiple IDOCs sent in a single Batch)
  • Target Message : External Messgae
  • Customer Master IDOCs will be sent from S4 HANA to CPI
  • CPI will have to create a new file on 3rd party SFTP per unique Company Code (Messages having a particular Company Code will be clubbed together in one file)

Sample Input : 

Sample%20Input%20Having%202%20Company%20Codes

Sample Input Having 2 unique Company Codes

Output Expected : 2 Files, one for 1156 Company Code and other for 1152 (As a Sample case, here Mail adapter is used instead of SFTP)

CPI iFlow Sample : 

To mock a scenario-Content Modifier holds the IDOC data here, post which individual IDOCs are split in a general splitter. IDOC-External definition mapping is done in next step and aggregated further.

CPI%20iFlow%20%28Sample%20only%29

CPI iFlow Sample with Aggregation Condition

Using an Aggregator pattern, we can collect and store individual messages until a complete set of related messages have been received. The aggregated message is then sent to the actual receiver (One message per unique value in Correlation Condition)

We use an Aggregator to group all messages related to a particular Company Code by giving the Correlation Expression. (In the image above, the XPath in Aggregator Correlation is taken from External message post mapping)

Output : 

Output%20showing%202%20separate%20eMails%20received%20for%20each%20unique%20customer%20code

Output showing 2 separate eMails received for each unique customer code

 

Pros : 

  • Instead of writing complex mappings to achieve the above requirement, Aggregator makes it easier to group the message based on Correlation condition

Cons :

  • Aggregator expects a waiting time, which means once data is received in an aggregator, it will wait for that amount of time after which it will send output to further steps.

Additional Observations :

Scenarios wherein grouping messages having a particular similar value like above is required, but instead of creating 2 separate files like above, only 1 file is required which contains data related to both company codes segregated within file at output, the use of Aggregator may have a limitation here.

However, would welcome integration experts to add observations and comments w.r.t the same.

Summary

The use of Aggregator in CPI with a simple use case was explained above.

Comments or feedback/suggestions, pros/cons with respect to the above are welcome from fellow Integration folks.

References :

Sara Sampaio

Sara Sampaio

Author Since: March 10, 2022

0 0 votes
Article Rating
Subscribe
Notify of
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x