Skip to content

ABAP Keyword Documentation →  ABAP - Reference →  Processing External Data →  ABAP Database Accesses →  Open SQL →  Open SQL - Streaming and Locators 

Open SQL - Locators

Open SQL supports locators for LOBs in database tables.

Other versions: 7.31 | 7.40 | 7.54

System Classes for Locators

The associated system classes for the two types of LOBs are:

  • CL_ABAP_DB_C_LOCATOR for CLOBs.
  • CL_ABAP_DB_X_LOCATOR for BLOBs.

The instances of the classes above belong to the LOB handles and implement the corresponding interfaces. Usage in Open SQL involves reference variables which point to the relevant LOB handles.

Important Methods

Locators contain the following methods which are implemented as kernel methods. This means that access to LOBs is completed by the ABAP runtime environment.

Methods in Both Locator Types

  • GET_LENGTH returns the length of the LOB that is connected to a locator.

  • FIND searches from an offset for a sub-sequence of an LOB which is connected to a locator, and returns its position. The length of a character type sub-sequence which can be searched for using FIND is limited to 1333 characters in Unicode systems and to 2666 characters in non-Unicode systems. The length of a binary sub-sequence is always limited to 2666 bytes.

Methods from the IF_ABAP_CLOSE_RESOURCE interface:

  • CLOSE closes the locator.
  • IS_CLOSED returns "X", if the locator is closed.

Methods in Character-Like Locators

  • GET_SUBSTRING returns the sub-sequence specified using offset and length, of a CLOB which is connected to a locator.

Methods in Binary Locators

  • GET_BYTES returns the sub-sequence, specified using offset and length, of a BLOB which is connected to a locator.

Creating Locators for LOBs

A locator that is bound to an LOB, that is, an instance of the class CL_ABAP_DB_C_LOCATOR or CL_ABAP_DB_X_LOCATOR, can only be created if, in the INTO clause of the SELECT statement, an LOB from the result set is assigned to a reference variable for a locator.

Refer to SELECT - LOB Handles.


Note

The creation of locators is not possible in changing Open SQL statements. However, locators which were created in a read statement can be used to make changes.

Closing Locators

Due to high resource consumption, locators must always be closed as soon as possible using their CLOSE method. Especially when creating locators in SELECT loops, consider that locators are not closed implicitly using ENDSELECT, unlike read streams, and must be closed explicitly. Furthermore, locators are closed implicitly at the end of a database LUW.