on 09-22-2010 8:45 AM
Hi.
I get a string in a field that I want to covert into many segments with a field containing parts of the string.
Here's an example of a string.
S1265159S1265165S32007S32009S00612
This string should create an segment for each S part
The result should be
<segment>
<field>S1265159<field/>
<segment/>
<segment>
<field>S1265165<field/>
<segment/>
<segment>
<field>S32007<field/>
<segment/>
<segment>
<field>S32009<field/>
<segment/>
<segment>
<field>S00612<field/>
<segment/>
I've mapped the incoming field to the segment and to the field with an UDF that looks as follow.
public void StringToSnote(String[] a,ResultList result,Container container){
String[] results = a[0].split("S");
String outdata = "";
for (int i=0; i<results.length; i++) {
if(results<i>.length()>0)
{
if(results<i>.length()>8)
{
outdata = "S"+results<i>;
outdata = outdata.substring(0,8);
}
else
{
outdata = "S"+results<i>;
}
result.addValue(outdata);
result.addValue(ResultList.CC);
}
}
}
It only creates the first segment.
The qeues looks ok according to me and the correct number of segments should have been created.
What have I missed?
BR
Kalle
you need a similar function to map it to segment also.
segemnt queue needs as many entries as field, but no CC
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
create 2 udf's:
UDF1:
String delimiter ="S" ;
String[] temp = var1[0].split(delimiter);
for(int i=0;i<temp.length;i++)
{
if(temp<i>.length()>0)
{
result.addValue("");
}
}
UDF2:
String delimiter ="S" ;
String[] temp = var1[0].split(delimiter);
for(int i=0;i<temp.length;i++)
{
if(temp<i>.length()>0)
{
String a = "S" + temp<i>;
result.addValue(a);
result.addValue(ResultList.CC);
}
}
Mapping:
Source-> UDF1->Segment
Source -> UDF2-> filed
Thanks
Amit
User | Count |
---|---|
91 | |
10 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.