This blog is created to throw some lights on SAP CPI concepts, which experienced in my journey. Trying to explore more about HCI/Cloud platform integration/SCPI and sharing the contents to help you. Thanks for all Users your support. Please give your comments below ...
Tuesday, 8 August 2023
Remove XML hierarchy (multiple levels)nodes from the xml
import com.sap.gateway.ip.core.customdev.util.Message;
import java.util.HashMap;
import groovy.xml.XmlUtil;
import groovy.util.*;
def Message processData(Message message) {
def body = message.getBody(java.lang.String) as String;
def xml = new XmlSlurper().parseText(body)
xml.Lines.SerialNumber.Sub_Component.children().findAll { it.name() == 'SubCompDescription' }.replaceNode {}
xml.Lines.SerialNumber.children().findAll { it.name() == 'ItemDescription' }.replaceNode {}
body = XmlUtil.serialize(xml)
message.setBody(body);
return message;
}
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment