Skip to Content
avatar image
Former Member

PI Mapping requirement

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

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • avatar image
    Former Member
    Nov 03, 2009 at 01:28 PM

    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));
                }
            }
    
    

    Add comment
    10|10000 characters needed characters exceeded