on 12-07-2010 9:18 AM
Hi All,
I have a requirement,where only when the combination of 2 fields values are unique,node needs to be created in the target .
How to achieve this in Message mapping.
Ex
Field1 Field2 Target
1 2 Node formed
2 1 Node formed
2 2 Node formed
3 1 Node formed
3 1 node should not be formed
Hi,
I created the required mapping. This is the test data I was using:
<?xml version="1.0" encoding="UTF-8"?>
<ns0:MT_test_src xmlns:ns0="urn:test2">
<item>
<Field1>1</Field1>
<Field2>2</Field2>
</item>
<item>
<Field1>2</Field1>
<Field2>1</Field2>
</item>
<item>
<Field1>2</Field1>
<Field2>2</Field2>
</item>
<item>
<Field1>2</Field1>
<Field2>1</Field2>
</item>
</ns0:MT_test_src>
This is the XML in and out:
[http://www.freeimagehosting.net/uploads/282404ad27.jpg]
This is the Graphic mapping used and the overview of the Message Type:
[http://www.freeimagehosting.net/uploads/c48c096b0b.jpg]
Hope this helps...
Edited by: Ofer Even-Tsur on Dec 7, 2010 3:00 PM Fixed second image URL
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello,
The mapping suggested by Ofer is correct, however, it can still be simplified by adding collapseContext right after the splitByValue for the item mapping. e.g
Field1 --> concat --> sort:ascending -->splitByValue:valueChanged --> collapseContext --> item
Field2 --> /
Hope this helps,
Mark
Edited by: Mark Dihiansan on Dec 8, 2010 3:29 AM
Hi All,
Thanks for your responses.
My issue resolved
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi All,
Thank you for the responses.
But in my case the values coming are not constant values so i cannot use FIXVALUE.
Is there any other method to acheive this in Message Mapping.
I tried concatenation of values>sort>splitvalue(value change)>collapse context-> target node(segment).Its working
But its not working for field level.
Can any one help me on this
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
>
> Hi All,
> I have a requirement,where only when the combination of 2 fields values are unique,node needs to be created in the target .
> How to achieve this in Message mapping.
>
> Ex
>
> Field1 Field2 Target
> 1 2 Node formed
> 2 1 Node formed
> 2 2 Node formed
> 3 1 Node formed
> 3 1 node should not be formed
No need to go for UDF. This can be easily done by combination of standard functions concat , FixValues and createIf.
Concate your 2 fields and maintain it in key of FixValues and keep the value as true for which node should be create So node would only be created when it satisfy the comination.
Maintain your FixValues with default as false.
Key Value
12 true
21 true
22 true
.................
Field1---
| concat ---- FixValues --- createIf --- Target
Field2---
Regards,
Sunil Chandra
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Ramesh,
You need to write a UDF to check the field 1 and field2 are equal. If equal, then use the Createif node function to create the node.
Thanks,
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hey,
public class CompareTwoStrings {
public static void main(String[] args) {
// this will print; the compiler is smart
String s1 = "smile";
String s2 = "smile";
// this will print
if (s1 == s2)
System.out.println("s1 and s2 are ==");
}
}
and return the value and use createif funtion.
Regards
Pothana
Edited by: Pothana Yadav on Dec 7, 2010 11:08 AM
The easiest way is probably a UDF in which you loop over field1 and field2 and add true/false
to the resultqueue. as per your requirement. You can use the createif function to create the target
based on the UDF's resultqueue.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
80 | |
9 | |
9 | |
7 | |
7 | |
6 | |
6 | |
6 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.