on ‎2021 Oct 12 11:06 AM
Hello together,
I have a problem with my message mapping.
I try to split the following split. As the output i get both parts of the splitted string, but i just want to have the first part.
Format of the String:
008E7S54|XD56
Output:
<messbeleg><id>008E7S54</id><id>XD56</id></messbeleg>
Expected Output:
<messbeleg><id>008E7S54</id></messbeleg>
This is the Split-Function:
https://answers.sap.com/questions/13121983/sap-cpi-split-a-string-at-delimiter-and-add-contex.html
def void addContextChange(String[]input,Outputoutput, MappingContext context){for(item ininput[0].split('|')){output.addValue(item);}}
This is my message mapping.
How is it possible to get the first part of the splitted string as the output?
I hope someone can help me. 🙂
Regards
Henrik
Request clarification before answering.
Hi Henrik,
I think the split function returns an array and this bit of your code:
output.addValue(item)
Suggests to me that maybe it is adding each value in the array in to the output?
I think there should be some way to only add the first item value - maybe something like:
output.addValue(item[0]) - which I think will add the first value in the array only to the output.
Just a suggestion and I could be way off but basically I think you need to find a way to manage the array after it has been split.
Kind regards,
David
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
| User | Count |
|---|---|
| 13 | |
| 8 | |
| 6 | |
| 5 | |
| 4 | |
| 3 | |
| 2 | |
| 2 | |
| 2 | |
| 2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.