on 12-26-2018 8:32 AM
Hello experts,
I am working with Cloud Platform Integration, but I headed into this speed bump:
I have the following XML Format:
<root>
<textContent>First Text</textContent>
<textContent>Second Text</textContent>
</root
As you can see, I have 2 different texts, each one inside a tag (textContent) I wish to concatenate those two texts and pass them into a single tag within the target:
<targetRoot>
<text>First Text, Second Text</text>
</targetRoot>
I tried a lot of different things, split by value, then concatenate, remove contexts, however it assigns just the last text, and I need it to iterate for each <textContent> concatenate them and sent them int only one target tag.
Does anybody have insights of what am I missing here?
Regards,
Hello Melvin,
You need to create custom function to achieve the same.Below is how you can do it.
Custom Function Script:
import com.sap.it.api.mapping.*;
//Add Output parameter to assign the output value.
def void custFunc2(String[] is, Output output, MappingContext context)
{
def outputVal="";
for ( int i=0;i<is.length;i++)
{
outputVal= outputVal + is [i]
}
output.addValue(outputVal);
}
Screenshot of Mapping:
Regards,
Sriprasad Shivaram Bhat
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Sriprasad
You missed the comma separation of the values. The function can be reduced to:
import com.sap.it.api.mapping.*
def void appendQueue(String[] strings, Output output, MappingContext context) {
output.addValue(strings.join(", "))
}
Regards,
Morten
User | Count |
---|---|
67 | |
8 | |
8 | |
6 | |
6 | |
5 | |
5 | |
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.