Query Service Components
A query is represented by a query object, which is managed by a Query Manager (also an object). The Query Manager represents the query service against the ABAP program.

To create a Query Manager you need the static method GET_QUERY_MANAGER of the general system service class CL_OS_SYSTEM.
The ABAP program does not work with the Query Manager and query using class reference variables. Instead it accesses them using interfaces IF_OS_QUERY_MANAGER and IF_OS_QUERY and IF_OS_QUERY_FACTORY (see also Example).
Most of the components of system service class CL_OS_SYSTEM are used internally by the object services. A method must be used in an application program to be able to work explicitly with object-oriented queries.
This static method gives you the return parameter RESULT of type IF_OS_QUERY_MANAGER containing a reference to the Query Manager. The Query Manager is created when you initialize the object services.
The Query Manager manages the object-oriented queries of the ABAP program and is executed from interface IF_OS_QUERY_MANAGER.
Creates a query and returns a reference to the query object in return value RESULT of type IF_OS_QUERY. The filter condition is passed to parameter I_FILTER of type string, the sort condition is passed to parameter I_ORDERING of type string. If the query’s parameters should be specified using a parameter list, this has to be passed to parameter I_PARAMETERS of type string.
Queries are executed from interfaces IF_OS_QUERY and IF_OS_QUERY_EXPR_FACTORY.
Returns a reference to a query expression factory in the return parameter RESULT of type IF_OS_QUERY_EXPR_FACTORY (from a technical point of view, a query expression factory is part of a query object, although it is executed from interface _OS_QUERY_EXPR_FACTORY just like a separate object).
Sets the filter condition. The internal display of the filter condition that is created with a query expression factory is passed to parameter I_FILTER_EXPR of type IF_OS_QUERY_FILTER_EXPR.
Sets the parameter list of the filter condition. The internal display of the parameter list that is created with a query expression factory is passed to parameter I_PARAMETERS_EXPR of type IF_OS_QUERY_PARAMETERS_EXPR.
Sets the sort condition. The internal display of the sort condition that is created with a query expression factory is passed to parameter I_ORDERING_EXPR of type IF_OS_QUERY_ORDERING_EXPR.
Creates the internal displays of the filter condition, the parameter list and the sort term if these have not been created or set.
Creates either a filter condition in the form
attr1 operator attr2,
where attr1, operatorand attr2 are the values of parameters I_ATTR1, I_OPERATOR and I_ATTR2, or a filter condition in the form
attr1 operator 'val' or attr1 operator val_w_quotes,
where val and val_w_quotes are the values of parameters I_VAL and I_VAL_W_QUOTES.
If parameter I_IDX of type i is passed, for val the value of the parameter from the parameter list is used, whose index at the time when the query is executed is determined by the value of parameter I_IDX.
The filter condition that is created is returned in the return value RESULT of type IF_OS_QUERY_FILTER_EXPR.
Depending on the value of parameter I_NOT, creates a filter condition in the form
attr [NOT] LIKE 'pattern'or attr [NOT] LIKE pattern_w_quotes,
where attr, patternand pattern_w_quotes are the values of parameters I_ATTR, I_PATTERN and I_PATTERN_W_QUOTES.
If parameter I_IDX of type i is passed, for pattern the value of the parameter from the parameter list is used, whose index at the time when the query is executed is determined by the value of parameter I_IDX.
Passing one of the parameters I_ESCAPE or I_ESCAPE_W_QUOTES appends the definition of an escape character in the form
... ESCAPE 'escape' or ... ESCAPE escape_w_quotes
to the filter condition, where escape and escape_w_quotes are the values of parameters I_ESCAPE and I_ESCAPE_W_QUOTES.
The filter condition that is created is returned in the return value RESULT of type IF_OS_QUERY_FILTER_EXPR.
Depending on the value of parameter I_NOT, creates a filter condition in the form
attr IS [NOT] NULL,
where attr is the value of parameter I_ATTR.
The filter condition that is created is returned in the return value RESULT of type IF_OS_QUERY_FILTER_EXPR.
Creates a filter condition in the form
attr EQUALSREF ref,
where attr is the value of parameter I_ATTR and ref is the value of the parameter from the parameter list, whose index when the query is executed is determined by the value of parameter I_IDX.
Instead of using a parameter, the persistent object reference can also be set by specifying the instance GUID and class GUID using parameters I_GUID and I_CLSGUID of type OS_GUID.
The filter condition that is created is returned in the return value RESULT of type IF_OS_QUERY_FILTER_EXPR.
Creates a filter condition in the form
NOT ( expr ),
where expr is a filter condition that has already been created and passed to parameter I_EXPR.
The filter condition that is created is returned in return value RESULT.
Creates a filter condition in the form
( expr1 ) AND ( expr2 ),
where expr1 or expr2 are filter conditions that have already been created and passed to parameters I_EXPR1 or I_EXPR2.
The filter condition that is created is returned in return value RESULT.
Creates a filter condition in the form
( expr1 ) OR ( expr2 ),
where expr1 or expr2 are filter conditions that have already been created and passed to parameters I_EXPR1 or I_EXPR2.
The filter condition that is created is returned in return value RESULT.
Creates a parameter list. The parameter list that is created is returned in the return value RESULT of type IF_OS_QUERY_PARAMETERS_EXPR.
The parameters are appended in succession when method APPEND of a further interface IF_OS_QUERY_PARAMETERS_EXPR is called. The parameter name is passed to parameter I_PAR.
Creates a sort condition. The sort condition is returned in the return value RESULT of type IF_OS_QUERY_ORDERING_EXPR.
The attributes by which you are sorting are appended in succession when you call method APPEND_ASCENDING or APPEND_DESCENDING of additional interface IF_OS_QUERY_ORDERING_EXPR. The parameter name is passed to parameter I_ATTR.