on 2024 Dec 10 4:52 PM
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!
Request clarification before answering.
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("")
}
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
42 | |
6 | |
6 | |
5 | |
4 | |
4 | |
3 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.