cancel
Showing results for 
Search instead for 
Did you mean: 

PI Mapping requirement

Former Member
0 Kudos

Hi Experts,

My requirement is as follows:

I have a segment at output side.............. which 0 to unbounded......

It gets mapped from a field in input side which is also 0 to unbounded.

The requirement is such that...... I need to concatenate all the input fields value and calculate the length. If the length is greater than 60, I need to create multiple segment on the output side.

e.g Input repeats 3 times and the value is of length 70,70 and 60. So the total is 200 characters. Then I need 4 segments: 1st with 0-60 other with 61-120 next with 121 to 180 and the last with 181 to 200

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

hi yo can use and UDF

try this.


input   inputList (your values)
          sizeSplitList (the length- for your case is 60)

        
        int targetLen = 0;
        int sourceLen = 0;
        int count = 0;
        int pos = 0;
        for (int i = 0; i < inputList.length; i++) {
          
            if (inputList<i>.trim().equals("") ) {
            result.addValue(ResultList.SUPPRESS);
            }
            else {    
            if (i < sizeSplitList.length)
                targetLen = Integer.parseInt(sizeSplitList<i>);            
           sourceLen = inputList<i>.length();
            count = sourceLen/targetLen;
            pos = 0;
            
            while (pos < count * targetLen) {
                result.addValue(inputList<i>.substring(pos, pos + targetLen));
                pos += targetLen;
            }
            if (pos < sourceLen)
                result.addValue(inputList<i>.substring(pos));
            }
        }