cancel
Showing results for 
Search instead for 
Did you mean: 

maybe using a UDF?

former_member745782
Active Participant
0 Kudos

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

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

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++)
{
result.addValue("");
}

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

former_member745782
Active Participant
0 Kudos

thanks so much Amit!

this is perfect solution.

i just added a splitByValue before FIELD1 , FIELD2 and FIELD3

thanks so much

Answers (1)

Answers (1)

maciej_jarecki
Contributor
0 Kudos

Hi

Yes, use udf it will be the fastest solution. Use udf for whole context, and in input filed change context to higher element

Regards

Maciej