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
Pick all the values from XML and check for the condition using groovy script in SAP CI
import com.sap.gateway.ip.core.customdev.util.Message;
import java.util.HashMap;
import java.text.SimpleDateFormat;
import java.util.TimeZone;
import org.joda.time.*;
import groovy.json.*
def Message processData(Message message) {
def body = message.getBody(java.lang.String) as String;
def scs = new XmlSlurper().parseText(body)
def accno = scs.InvTransDoc.InventoryTransaction.'**'.find {it.name() == 'AccountNumber'}?.text()
def fromLocCode = scs.InvTransDoc.InventoryTransaction.'**'.find {it.name() == 'fromLocationCode'}?.text()
def toLocCode = scs.InvTransDoc.InventoryTransaction.'**'.find {it.name() == 'toLocationCode'}?.text()
if(fromLocCode == "FSLHOLD" | fromLocCode == "FSLDAMAGED" | fromLocCode == "FSLMISSING")
{
message.setHeader("LocationCode",toLocCode);
}
else
{
message.setHeader("LocationCode",fromLocCode);
}
message.setHeader("StorLoc",accno);
return message;
}
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment