Splitting of messages dynamically using parameterize mapping.
INTRODUCTION:
Writing for the first time in SCN so please bear with me, as we all improve with our experience. 🙂
Requirement was to split incoming message on the basis of threshold value, example if the target system accepts only 100 records per messages, and if a message more than 100 records is created we used to get Time out Error in receiver channel. So we need to split the message on the basis of number of records third party accept.
For each interface threshold value is different as we are mapping HRMD IDOC to the target xsd, we have different size of target payload for each interface, which results in different threshold values for interfaces to over come this we have used parameterized mapping instead of hard coding the values.
Changes done in ESR:
- Change occurrence 0…Unbound of your root node and the record node (in my case we have only 100 records per message can process)
- Change the occurrence of target message in signature tab of message mapping and occurrence needs to be changed in Operation Mapping.
Below screen prints for reference.
- For node <record> and its parent node <insertMultiple> we need to create UDF for occurrence of record node up to threshold value.
Mapping for <InsertMultiple> contains UDF SplitNode it has two inputs : Count for no. of occurrence and Constant (which contains threshold value will use Parameterize for this.)
***SplitNode***
public void SplitNode(int[] ActualCount, String[] Range, ResultList result, Container container) throws StreamTransformationException{
int reminder=0;
int quotient=0;
int z= (Integer.parseInt(Range[0]));
quotient=(ActualCount[0]) / z;
reminder=ActualCount[0]%z;
if(reminder > 0)
{
quotient = quotient + 1;
}
for(int i =0;i<quotient;i++)
{
result.addValue(“”);
}
Mapping for <record> contains UDF SplitRecordNode it has three inputs : Count for no. of occurrence, source field value and Constant (which contains threshold value will use Parameterize for this.)
***SplitRecordNode***
public void SplitRecordNode(int[] ActualCount, String[] Range, String[] Status, ResultList result, Container container) throws StreamTransformationException{
int z=(Integer.parseInt(Range[0]));
int cnt=0;
int temp=0;
int x =ActualCount[0]/z;
int y =ActualCount[0]%z;
for(int i =0;i<x;i++)
{
for(int j = 0;j<z;j++)
{
if ((Status[temp].equals(“true”)))
{
result.addValue(temp+””);
cnt++;
temp++;
if(cnt >=z)
{
cnt = 0;
- result.addValue(ResultList.CC);
}
}
else {
- result.addValue(ResultList.SUPPRESS);
temp++;
}
}
}
for(int i =0;i<y;i++)
{
if (Status[temp].equals(“true”))
{
result.addValue(temp+””);
cnt++;
temp++;
if(cnt >=z)
{
cnt = 0;
result.addValue(ResultList.CC);
}
}
else {
- result.addValue(ResultList.SUPPRESS);
temp++;
}
}
Parameterized mapping:
- In the message mapping (on the Signature tab), define the parameters to be used in the target field mapping
I will not explain properties of Parameter mapping as we have enough documents related to same, However I have taken Simple Type Category so that Values can be changed in future easily.
In operation mapping (that references the message mapping), create parameters (by choosing Parameters) and connect them with those of the message mapping (by choosing Binding).
Refer to below screen shots
Integration Builder:
Now the value can be entered for the parameters from the following locations:
- If you are using Classical scenario we can initialize the value in the interface determination which uses the operation mapping.
- In our case we have used ICO so I have initialized the values in Receiver Interface Tab for respective Operation Mappings
Result:
For testing purpose we can maintain parameter value I have set the same as 2, so currently we are having 10 record and as per above code, we will be having 2 records per messages.
Welcome to world of blogging. Looking forward for more!!
Great blog..!!
I have been searching for this...!! Finally got it from you...!!
Good to see you bloogging.All the best
Regards,
Vishnu Srivastava
Good information on splitting messages...
Excellent Blog
Very informative blog....Keep posting such useful blogs..:):)
Nice Blog...Information is very useful...
Keep Blogging.!!! 🙂
Hi Rakesh, Blog is nice. I have one doubt , how you are calculating the number of records. Thanks in advance. Regards, Vijay
Hello Vijay,
Thanks for the feedback.
If you will check the screen shot of message mapping I have used Count function after the condition is true for creating record node, this count is then sent as Input parameter in the UDF.
Regards,
Rakesh Duggal
Very informative rakesh 🙂
Hi Rakesh,
Thanks for such a nice blog! Very well articulated.
Hope to see some more blogs from you in near future.
Regards,
Akhil
Hi Rakesh,
Thanks for sharing such a nice blog.
The information given is much informative and helpful.
Regards
Amitosh
Keep Writing Rakesh!!
Very useful blog.
Keep writing...
Very Informative Blog !