on 03-31-2012 11:18 AM
Hello All,
In mapping i need to output the source values in a reverse order and mapped it to the Target filed.
For example:
Source Structure:
<MT_Source>
<Detail>
<Field1>200</Field1>
</Detail>
<Detail>
<Field1>100</Field1>
</Detail>
<Detail>
<Field1>300</Field1>
</Detail>
<like this I will be having n number of Detail>
</MT_Source>
Target Structure:
<MT_Target>
<Details>
<Field1>300</Field1>
<Field1>200</Field1>
<Field1>100</Field1>
</Details>
</MT_Target>
Regrads
Vasant
Hi,
You can achieve this using 2 lines of code....
UDF:
input will be a
Exceution type: all values of a context
for(int i=a.length-1;i>=0;i--)
{
result.addValue(a[i]);
}
Your mapping will be:
Input---RemoveContext--Sort---UDF--Output
Thanks
Amit Srivastava
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
just to add to Amit's reply above, everything seems fine except in mapping step:
Input---RemoveContext--Sort---UDF--Output
Here Sort is not needed. So it should be like below:
Input field - RemoveContext - UDF - Output field
or you can try:
Input field Field1(right click context change to MT_Source) - UDF - Output field Field1
Thanks Rajeev and Ankit for correcting me.....there is a bit of contrast between subject and example shown above and may be becoz of that i have added sort anywayz i guess Vasant can only clarify what actually he wants...
@Vasant
yes indeed sort is not required if u want to output the source values in reverse sequence...UDF and RC will help u...
Thanks
Amit Srivastava
Hi Vasant,
I am sure you have taken Field1 inside target structure occurrence as 0..unbound. Secondly, if you need fields in reverse order Amit's UDF will do that, remove sort before it.
But in your example for target structure you shown values in decreasing order on target not in reverse order. If you need values in decreasing order. No need to use UDF, just use Sort function and do descending sort.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
78 | |
9 | |
9 | |
7 | |
7 | |
6 | |
6 | |
5 | |
5 | |
5 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.