Monday 11 October 2021

Groovy script for picking the field from xml in array and select the particular value

 

Groovy script

import com.sap.gateway.ip.core.customdev.util.Message;
import java.util.HashMap;
import groovy.json.*;
import groovy.util.logging.*;
import org.codehaus.*;


def Message processData(Message message) {
def body = message.getBody(java.lang.String) as String;


def XmlDataObject = new XmlSlurper().parseText(body)


def xmldata = []
def s="";
XmlDataObject.'**'.findAll { it.name()== 'UserServiceTransactionProcessingTypeCode'}.each { a ->
xmldata << a.text() }

message.setProperty("StatusCode",xmldata);
def newxmldata = xmldata as String[]
newxmldata = newxmldata.contains("ZCW1")

message.setProperty("StatusCode1",newxmldata);

return message;


}




2 comments:

  1. cloud-based software platform
    Cloud-based deployments of business applications is therefore on the rise for some very good reasons – it enhances business and technological agility, accelerates time to market and time-to-value and increases economies of scale.

    ReplyDelete
  2. If you are Looking for SAP Training in the USA? We are providing the greatest training facilities to the students to do their career aims better and earlier. Get in touch with us for more details, our support team will be grateful to help you anytime.

    ReplyDelete