INTRODUCTION:
Writing for the first time in SCN so please bear with me, as we all improve with our experience. :smile:
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:
Below screen prints for reference.
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;
}
}
else {
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 {
temp++;
}
}
Parameterized 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:
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
8 | |
5 | |
5 | |
4 | |
4 | |
4 | |
4 | |
4 | |
3 | |
3 |