Show TOC

Filtering Business Object Instances in Application ServiceLocate this document in the navigation structure

Use

In the Service Composer perspective of the SAP NetWeaver Developer Studio you can model different query methods for your business objects. At runtime you should specify conditions and values for each attribute by using the class QueryFilter. You can specify that you want to use a list of query filters. You have the following options when modeling query methods to search for business object instances:

  • Filter by one attribute.
  • Filter by two or more attributes of the business object. The logical rule applied between the attributes is AND.

To create and apply query filters use the following java class:

Class: com.sap.caf.rt.bol.util.QueryFilterFactory

DC: caf/runtime/ear

PP: api

Syntax

The table below lists the available filter conditions. You can use them when you create query filters.

Conditions and Types for Which They Are Available

Condition and Description boolean String Others

CONDITION.EQ (==) (default)

Must be equal to value .

CONDITION.NEQ ( !=)

Must not be equal to value .

CONDITION.LT ( <)

Must be less than value .

CONDITION.GT ( >)

Must be greater than value .

CONDITION.LE ( <=)

Must be less or equal to value .

CONDITION.GE ( >=)

Must be greater or equal to value .

CONDITION.BETWEEN(<>)

Must be between valueLow and valueHigh inclusive.

Using Query Filters Types

You can create query filters by calling the suitable create methods. The table below describes how to create your own query filters, giving appropriate examples for the different possibilities.

Arguments Description and Examples

Value

Creates a query filter by a given value. The value type can be one of the following:

  • String
  • BigDecimal
  • BigInteger
  • XMLGregorianCalendar
  • java.util.Date
  • java.sql.Date
  • java.sql.Time
  • java.sql.Timestamp
  • Integer or int
  • Float or float
  • Double or double
  • Long or long
  • Boolean or boolean

QueryFilterqf = QueryFilterFactory.createFilter("New YorkHigh School");
  • Value and Condition

For the argument value , you can use the types listed above.

For the argument condition, you can use the enumeration CONDITION.*

QueryFilterqf = QueryFilterFactory.createFilter(
                               CONDITION.EQ,                     
                               " New York High School");
                       
/*Returns all instances with attributes equal to the given string.*/

Value Low and Value High

QueryFilter  qf = QueryFilterFactory.createFilterForBetween(3.5,6.0);

/*Returns all instances with attribute whose value is between 3.5 and 6.0 * inclusive/
Note

Note that if you call an operation that has a single query filter as an input and you pass null  the corresponding filter will be ignored and only the other filters, if any will be applied. If you call operation, that has a collection of query filters for input and you pass null or empty collection you will get an empty result, regardless of the other filters.

Using OrderBy and Paging

For each business object node finder method, CAF generates a corresponding method with two more parameters: OrderBy and Paging. You can use these methods to order the returned instances or, in the case of a very large result set, you can retrieve it in pages. For more information about constructing these parameters, see the javadocs of the following classes:

Class: com.sap.caf.rt.bol.util.OrderBy

Class: com.sap.caf.rt.bol.util.Paging

DC: caf/runtime/ear

PP: api