Skip to Content
Former Member
Jul 27, 2015 at 08:47 AM

OData Query operation with filter for 4 parameters


Hi Experts,

We have stuck in developing OData service with filter operation for 4 or more parameters for query operation.

we are able to do the filter for single paramater for query operation, but how can we implement the same for 4 parameters no idea.

below code works when we use the URL with filter for one paramater:

https://localhost:8083/gateway/odata/SAP/MYEMP;v=1/Set?$filter=DataID eq 'Ray'

here we have one input parameter (Name) which we are passing value as Ray.


Function processRequestData will be called just after the Request

flow is triggered.

Implement processRequestData for additional functionalities as

$TOP, $SKIP, etc.

Prepare a HashMap and set it to message body. This HashMap has keys as

parameter names for the required web service operation, and values as

the values for those parameters.


function getUriInfo(message) {



var uriInfo = message.getHeaders().get(ODataExchangeHeaderProperty.UriInfo.toString());

return uriInfo;



var childMap2 = new LinkedHashMap();

function processRequestData(message) {


var odataMethod = message.getHeaders().get(ODataExchangeHeaderProperty.ODataMethod.toString());

var uriInfo = getUriInfo(message);

//if query oeration

if(odataMethod == "GET_FEED"){

if (uriInfo.getFilter() != null){


var whereExp = uriInfo.getFilter();




importPackage (;

log.logErrors(LogMessage.TechnicalError, "This is first log:::"+message.getBody().toString());


return message;


function parseToWhereExpression(whereExpression) {

importPackage (;



if (whereExpression.getKind() == 'FILTER') {

log.logErrors(LogMessage.TechnicalError, "***KIND** is Filter");

log.logErrors(LogMessage.TechnicalError, "***WhereExp** in Filter"+ whereExpression.getExpression());

return parseToWhereExpression(whereExpression.getExpression());


else if (whereExpression.getKind() == 'BINARY') {

log.logErrors(LogMessage.TechnicalError, "***KIND** is Binary" );

var binaryExpression = whereExpression;

var left = parseToWhereExpression(binaryExpression.getLeftOperand());

var right= parseToWhereExpression(binaryExpression.getRightOperand());


log.logErrors(LogMessage.TechnicalError, "***return** " + left + " EQ " +right);

return left + "EQ" +right;


else if (whereExpression.getKind() == 'PROPERTY') {

log.logErrors(LogMessage.TechnicalError, "***KIND** is Property" );

var property = whereExpression;


var prop = property.getEdmProperty();

var returnStr = prop.getName();

return returnStr;


else if (whereExpression.getKind() == 'LITERAL') {

log.logErrors(LogMessage.TechnicalError, "***KIND** is Literal" );


var literal = whereExpression;

var literalType = literal.getEdmType();

var value = literalType.valueToString(literalType.valueOfString(

literal.getUriLiteral(), EdmLiteralKind.URI, null,


EdmLiteralKind.DEFAULT, null);

return value;


else {

log.logErrors(LogMessage.TechnicalError, "***returning NULL****");



function processRequestXML(message) {

importPackage (;

log.logErrors(LogMessage.TechnicalError, "This is Request log:::"+message.getBody().toString());

return message;



Gets the SOAP request XML here. This method can be used if extra headers

need to be added to the XML request.



Gets the web service response XML. If the web service returns values which are not mapped to EDM types,

those values can be filtered out here e.g. In line count, eTag, etc.


function processResponseXML(message) {

importPackage (;

log.logErrors(LogMessage.TechnicalError, "This is second log:::"+message.getBody().toString());

return message;


function processResponseData(message) {

return message;


Now we have four parameter like: Name, LastName, Dept, EMPID.

these are four mandatory parameters which will retrieve the data accordingly this filter and no idea how to implement this filter operation.

Please help.