Monday, 2 March 2020

Groovy script for DateTime formatting ODATA filter





import com.sap.gateway.ip.core.customdev.util.Message;

import java.util.HashMap;

import java.util.TimeZone


def Message processData(Message message) {

//Body

def body = message.getBody();

//Properties

map = message.getProperties();

value = map.get("LastSuccessfulRun886PRD");

def curDateTime1 = "";

def tz = TimeZone.getTimeZone("Europe/Berlin")

def ts = new Date()

curDateTime1 = (ts.format("yyyy-MM-dd'T'HH:mm:ss", timezone=tz))

def datequery = "(CCSRQ_DOC_CREATED_DATE_TIME ge"+"'"+value+" CET"+"'"+" and CCSRQ_DOC_CREATED_DATE_TIME le"+"'"+curDateTime1+" CET"+"'"+")";

message.setHeader("datequery",datequery);

message.setProperty("CurrentDate",curDateTime1);

return message;

}



No comments:

Post a Comment