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 the json field and replace the existing property value in the payload using the script
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 ExtId1 = message.getProperty("ExternalId").toString().trim();
def body = message.getBody(java.lang.String) as String;
def jsonSlurper = new JsonSlurper();
def jsonDataObject = jsonSlurper.parseText(body);
jsonDataObject.header.externalid = ExtId1
message.setBody(new JsonBuilder(jsonDataObject).toPrettyString()) return message
}
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment