Groovy script:
import com.sap.gateway.ip.core.customdev.util.Message;
import groovy.xml.*;
import groovy.util.*;
import groovy.xml.MarkupBuilder;
def Message processData(Message message) {
def body = message.getBody(java.lang.String) as String
def payload = new XmlParser().parseText(body);
def mProp = message.getProperties();
String input = mProp.get("Cust_MessageDirect_FO_TORType");
String TOR_50 = mProp.get("Cust_FreightOrder_TORTypes");
String Typdecode_50 = mProp.get("Cust_Typecode_50");
String Typdecode_208 = mProp.get("Cust_Typecode_208");
String Typdecode_67 = mProp.get("Cust_Typecode_67");
def result = TOR_50.contains(input)
message.setProperty("TOR_IsMatch_50",result);
def Type_IsMatch_50="false";
def Type_IsMatch_208="false";
def Type_IsMatch_67="false";
def typdeCode = payload.TransportationDocument.TextCollection.Text.'*'.findAll{node->node.name()=="TypeCode"}*.text()
for(int i=0;i<typdeCode.size();i++)
{
if(Typdecode_50.contains(typdeCode[i]))
{
Type_IsMatch_50 = "true";
}
if(Typdecode_208.contains(typdeCode[i]))
{
Type_IsMatch_208 = "true";
}
if(Typdecode_67.contains(typdeCode[i]))
{
Type_IsMatch_67 = "true";
}
}
message.setProperty("Type_IsMatch_50",Type_IsMatch_50)
message.setProperty("Type_IsMatch_208",Type_IsMatch_208)
message.setProperty("Type_IsMatch_67",Type_IsMatch_67)
return message;
}
Input:
Cust_MessageDirect_FO_TORType = ZF02
Cust_FreightOrder_TORTypes = 'ZF01','ZF02','ZF03'
Cust_Typecode_50 = 'ZBYRC','ZBYPA'
Cust_Typecode_208 = ZTORT
Cust_Typecode_67 = ZFCPI
Output:
Returns true or false for all property values.
No comments:
Post a Comment