Search
Search

# maybe using a UDF?

hello everybody,

i have a very easy mapping to solve. I need change the structure from positional to linear.

I tried using graphical mapping but i was not able to solve.

I think is necessary to use a UDF function but not sure:

the source message is this:

```<RECORDS>
<R10>
<F1>3001</F1>
<F2>NR:2</F2>
</R10>
<R10>
<F1>3002</F1>
<F2>VA:1</F2>
</R10>
<R10>
<F1>3003</F1>
<F2>VA:65</F2>
</R10>
<R10>
<F1>3001</F1>
<F2>NR:5354</F2>
</R10>
<R10>
<F1>3002</F1>
<F2>VA:1</F2>
</R10>
<R10>
<F1>3003</F1>
<F2>VA:95</F2>
</R10>
</RECORDS>```

and i want obtain this:

```<RESULT>
<PLU>
<FIELD1>NR:2</FIELD1>
<FIELD2>NR:1</FIELD2>
<FIELD3>VA:65</FIELD3>
</PLU>
<PLU>
<FIELD1> NR:5354</FIELD1>
<FIELD2> VA:1</FIELD2>
<FIELD3> VA:95</FIELD3>
</PLU>
</RESULT>```

any suggestion?

thanks

Alex

##### Amit Srivastavareplied

Use UDF:

Input will be "a". Execution type : All values of a context

UDF:

```String s = "";
for(int z=0;z<a.length;z++)
{
s=s+a[z]+"," ;
}
String[] temp = s.split("3001,3002,3003");
for(int i=1;i<temp.length;i++)
{
}
```

Mapping:

1) F1(change its context to Records)---UDF--PLU

2) F1(change its context to Records)----

-

equals----IfWithoutElse(F2(change its context to Records)

THEN)-- FIELD1

Constant(3001)---

In the same way proceed for the other two fileds Field2, Filed3...

Assumption: The values in F1 are coming in the same order as shown in the post.

Thanks

Amit

0 View this answer in context