Custom Filters - Constant Comparison Filters

The query specification model defines comparison filters on constant values by using the <comparisonFilter> XML element. For each <comparisonFilter>, you need to add a <constantOperand> child element, which contains as many <answerValue> children as there are constant values used as right operands.

<filterPart>
    <comparisonFilter id="string" path="string" operator="string">
        <constantOperand searchPattern="true|false">
            <answerValue dataType="String|Numeric|Date">
<comparisonFilter> Attribute Description
id The identifier of the object used as left operand
path The full path of the object in the universe
operator The operator

The following table lists the possible values of the operator attribute and the number of operands the attribute accepts.

Operator operator Attribute Value Number of Right Operands
Is Null IsNull Zero
Is Not Null IsNotNull Zero
Equal To (=) EqualTo One
Not Equal To (<>) NotEqualTo One
Less Than (<) LessThan One
Greater Than (>) GreaterThan One
Less Than or Equal To (<=) LessThanOrEqualTo One
Greater Than or Equal to (>=) GreaterThanOrEqualTo One
Like Like One
Not Like NotLike One
Between Between Two
Not Between NotBetween Two
In InList List
Not In NotInList List

The <constantOperand> element has one attribute called searchPattern that you can use with the Like operator only. This attribute allows you to know how the <answerValue> value is parsed without knowing the escape and mask characters of the underlying database.

<constantOperand> Attribute Description
searchPattern If set to true, the <answerValue> value is parsed:
  • The * character is replaced with the multicharacter mask of the database in the resulting SQL.
  • The ? character is replaced with the single-character mask of the database in the reuslting SQL.
  • If the pattern contains \? or \*, then ? or * are escaped. Strings containing ? or * are actually found by the operator.
  • The _ and % wildcard characters are escaped.
If set to false, the value is not parsed. Default is false.
<answerValue> Attribute Description
dataType The data type of the value used as filter

Example

The following snippet of a query specification shows an EqualTo comparison filter with one constant operand in the query.

<query xmlns="http://www.sap.com/rws/sl/universe" id="5897899822041415615" dataSourceType="unx" 
    dataSourceId="5808">
    <querySpecification version="1.0">
        <queryOptions>
            ...
        </queryOptions>
        <queryData>
            <resultObjects>
                <resultObject path="Customer|folder\Geography|folder\Continent|dimension"
                    id="_IBo8M7IhEeCk0Ylv-tlF2Q"/>
                <resultObject path="Customer|folder\Geography|folder\Country|dimension"
                    id="_IBo8NrIhEeCk0Ylv-tlF2Q"/>
                <resultObject path="SalesOrders|folder\Number of Orders|measure"
                    id="_IB8eVbIhEeCk0Ylv-tlF2Q"/>
            </resultObjects>
            <filterPart>
                <comparisonFilter operator="EqualTo" path="Time|folder\Calendar|folder\Calendar 
                    Year|dimension" id="_IBo8FLIhEeCk0Ylv-tlF2Q">
                    <constantOperand>
                        <answerValue dataType="String">2011</answerValue>
                    </constantOperand>
                </comparisonFilter>
            </filterPart>
        </queryData>
    </querySpecification>
</query>