cancel
Showing results for 
Search instead for 
Did you mean: 

SAP Integration Suite Custom UDF in Message Mapping

nileshnagane12
Discoverer
0 Kudos
177

Hello SAP Community,

I need help creating a Groovy UDF to split a property value (containing a comma-separated string) into multiple values within the same context in SAP PI/PO message mapping.

For example, the property value:
item=000010,000030,000020

I want to extract each value (000010, 000030, 000020) as separate outputs in the same context.

Here’s the Groovy script I wrote:

def void getProperty(String propertyName, MappingContext context, Output output) {
def propertyValue = context.getProperty(propertyName)
if (propertyValue) {
def values = propertyValue.split(",")
values.each { value ->
output.addValue(value.trim())
}
} else {
output.addValue("")
}
}

However, the function doesn’t appear in the "Custom UDF" section. Can someone help identify what I might be doing wrong or suggest improvements to achieve this functionality?

Thank you!

 

 

 

View Entire Topic
Andrzej_Filusz
Contributor
0 Kudos

Hello,

Please check the following code:

import com.sap.it.api.mapping.*

def void getProperty(String[] propertyName, Output output, MappingContext context) {
    def propertyValue = context.getProperty(propertyName[0])
    if (propertyValue) {
        def values = propertyValue.split(",")
        values.each { value ->
            output.addValue(value.trim())
        }
    } else {
        output.addValue("")
    }
}
nileshnagane12
Discoverer
0 Kudos

Hi Andrej,

Thanks for the help. Script is working now