cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

SAP CPI - Message Mapping - Split Function Output

0 Likes
4,216

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

View Entire Topic
Sriprasadsbhat
Active Contributor

Hello Enrik,

Below should work,

def void addContextChange(String[] input, Output output, MappingContext context) { 
    def item=input[0].split(';')[0]	
    output.addValue(item);   
}

Regards,

Sriprasad Shivaram Bhat

0 Likes

Thank you Sriprasad,

this works fine.

Regards,

Henrik 🙂