Skip to content

ABAP Keyword Documentation →  ABAP − Reference →  Processing External Data →  ABAP Database Access →  Object Services →  Query Service 

Query Service Overview

A query is used to search for persistent objects in the database using conditions and to create the corresponding instances of the persistent class in the ABAP program.

A query is implemented by an object (query object) that implements the interface IF_OS_QUERY and is created by a query manager.

A query is a logical expression that compares the attributes of a persistent class with parameters or values that comprise the query condition. Those objects are loaded whose attributes meet the query conditions. A query also contains a sort condition, which determines the order of the loaded objects in the results table.

When a query is created using the query manager method CREATE_QUERY method, the query conditions and sort conditions are passed to it.

The query itself is merely a container for the query condition and the sort condition. A query is executed by calling the interface method IF_OS_CA_PERSISTENCY~GET_PERSISTENT_BY_QUERY in the class agent of a persistent class. Similarly, the result of an executed query is not bound to the query, but is returned by the class agent’s method as a table of references.

Other versions: 7.31 | 7.40 | 7.54


Note

When the result quantity of a query is determined, the changes that are made in the current transaction to persistent objects are not considered. The query is executed directly in the database.