on 08-05-2011 6:58 PM
Hi Gurus,
I need a target field to receive the last value of a source field, as you can see below:
Source:
SourceSegment(1..unbounded)
->SourceField(0..1)
Target:
TargetSegment(1..1)
->TargetField(0..1)
I have an example asi this:
<SourceSegment>
<SourceField>A</SourceField>
</SourceSegment>
<SourceSegment>
<SourceField>B</SourceField>
</SourceSegment>
<SourceSegment>
<SourceField>C</SourceField>
</SourceSegment>
So, what I need is to send the LAST value in the TargetField which will be generated only once:
<TargetSegment>
<TargetField>C<TargetField>
<TargetSegment>
Is this possible without an UDF?
Write a simple Queue cached udf and set the context of source element to top node.
public void lastvalue(String[] a,ResultList result,Container container){
int x;
String y = "";
x = a.length;
y = a[x-1];
result.addValue(y);
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
get the array size in the UDF and assign the last element of the array to the target element. Something like -
String len = input.length;
output = input[len-1];
VJ
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
84 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.