Checking payload content cpi groovy.
---------------
import com.sap.gateway.ip.core.customdev.util.Message;
import java.util.HashMap;
def Message processData(Message message)
{
def body = message.getBody(java.lang.String) as String;
// Split the payload into lines
def lines = body.split("\\r?\\n");
// Check if the payload contains "*997*" in the 3rd line starting with "ST"
if (lines.length >= 3 && lines[2].startsWith("ST") && lines[2].contains("*997*")) {
// If the condition is met, perform your desired action here
// For example, you can print a message
println("The payload contains *997* in the 3rd line starting with ST");
// Or you can set a flag or perform any other necessary logic
// For example, set a flag in a HashMap
HashMap<String, Object> properties = message.getProperties();
properties.put("Contains997", true);
message.setProperties(properties);
}
return message;
};

0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home