on 11-03-2009 11:01 AM
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
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));
}
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
86 | |
10 | |
10 | |
9 | |
6 | |
6 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.