Skip to Content
Author's profile photo Rakesh Duggal

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) 

/wp-content/uploads/2016/09/1_1044865.jpg

  • 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.

/wp-content/uploads/2016/09/2_1044869.jpg

/wp-content/uploads/2016/09/3_1044884.jpg


  • 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.)

/wp-content/uploads/2016/09/4_1044885.jpg


/wp-content/uploads/2016/09/5_1044886.jpg

***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.)

/wp-content/uploads/2016/09/6_1044887.jpg

***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;

  1. result.addValue(ResultList.CC);

        }

  }

else {

  1. 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 {

  1. 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

/wp-content/uploads/2016/09/7_1044888.jpg

/wp-content/uploads/2016/09/8_1044889.jpg

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

/wp-content/uploads/2016/09/9_1044890.jpg

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


/wp-content/uploads/2016/09/10_1045125.jpg


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.


13.JPG

Assigned Tags

      14 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Deepak Shah
      Deepak Shah

      Welcome to world of blogging. Looking forward for more!!

      Author's profile photo Vishnu Srivastava
      Vishnu Srivastava

      Great blog..!!

      I have been searching for this...!! Finally got it from you...!!

      Good to see you bloogging.All the best

      Regards,

      Vishnu Srivastava

      Author's profile photo Vineet Ruhela
      Vineet Ruhela

      Good information on splitting messages...

      Author's profile photo Former Member
      Former Member

      Excellent Blog

      Author's profile photo Former Member
      Former Member

      Very informative blog....Keep posting such useful blogs..:):)   

      Author's profile photo Former Member
      Former Member

      Nice Blog...Information is very useful...

      Keep Blogging.!!! 🙂

      Author's profile photo Vijay Kapuganti Kumar
      Vijay Kapuganti Kumar

      Hi Rakesh, Blog is nice. I have one doubt , how you are calculating the number of records. Thanks in advance. Regards, Vijay

      Author's profile photo Rakesh Duggal
      Rakesh Duggal
      Blog Post Author

      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

      Author's profile photo Former Member
      Former Member

      Very informative rakesh 🙂

      Author's profile photo Akhil Kumar
      Akhil Kumar

      Hi Rakesh,

      Thanks for such a nice blog! Very well articulated.

      Hope to see some more blogs from you in near future.

      Regards,

      Akhil

      Author's profile photo Amitosh Srivastava
      Amitosh Srivastava

      Hi Rakesh,

      Thanks for sharing such a nice blog.

      The information given is much informative and helpful.


      Regards

      Amitosh

      Author's profile photo vishwajeet ahluwalia
      vishwajeet ahluwalia

      Keep Writing Rakesh!!

      Author's profile photo Former Member
      Former Member

      Very useful blog.

      Keep writing...

      Author's profile photo Former Member
      Former Member

      Very Informative Blog !