on 03-02-2009 6:11 AM
Hey everyone!
I have a mapping task where I need to get all the values of a multiple occuring field in the source interface, then pass the values to a single field in the target interface.
eg. name >>>mapped to>>> names
SOURCE:
<Set>
<name>john</name>
</Set>
<Set>
<name>harry</name>
</Set>
<Set>
<name>mike</name>
</Set>
<Set>
<name>james</name>
</Set>
DESIRED RESULT:
<target>
<names>john harry mike james</names>
</target>
Do I need to create a queue UDF for this?
Kind regards,
Glenn
yes create a Queued UDF.
loop through the input queue and concat to a result string.
psedocode;
String resultstring = "";
for (int a; a< input.length(); a++)
{
resultstring = resultstring + input[a];
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
When you create the UDF make sure your input parameter is renamed to input (by default it is a of type string)
String resultstring = "";
for (int a; a< input.length(); a++)
{
resultstring = resultstring + input[a];
}
result.addValue(resultstring);
if you still get an error, please let me know what is the description of the same.
Hey Shabarish!
I'm getting the ff exception with your new code:
Source code has syntax error: /usr/sap/PID/DVEBMGS00/j2ee/cluster/server0/./temp/classpath_resolver/Map95c6474006f411de92ea0003ba710785/source/com/sap/xi/tf/_DFS_CHNG_ERP_MM_.java:3629: cannot resolve symbol symbol : method length () location: class java.lang.String[] for (int a; a< input.length(); a++) ^ 1 error
Glenn
Hi,
Alternatively, you may use this mapping:
Set --> removeContext --> UDF --> targetNode
UDF type is of Context, argument is input
StringBuffer e = new StringBuffer();String b = null;
for (int i=0;i<input.length;i++){e = e.append(input<i> + " ");}
b = e.toString();
result.addValue(b);
StringBuffer would use less memory, same with queue as compared to context.
Hope this helps,
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
U need to change the context of "name" to its root node..then only it will give expected output.
Regards,
Manisha
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi
you can use, concat function..if it is only as mentioned above
Regards
Vishnu
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
85 | |
10 | |
10 | |
9 | |
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.