Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 

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:

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

  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


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.



14 Comments
Labels in this area