SAP LOCATORS



Get Example source ABAP code based on a different SAP table
  


• CL_ABAP_DB_C_LOCATOR ABAP_CLASS
• CL_ABAP_DB_X_LOCATOR ABAP_CLASS

AB_SQL - Locators
AB_SQL supports locators for LOBs in data sources.
ITOC

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 are LOB handles and implement the corresponding interfaces . Their use in AB_SQL involves reference variables that point to LOB handles of this type.

Important Methods
Locators contain the following methods
BEGIN_SECTION VERSION 5 OUT that are implemented as kernel methods
END_SECTION VERSION 5 OUT . The actual access to LOBs is performed by the ABAP runtime framework.

Methods in Both Locator Types
GET_LENGTH returns the length of the LOB that is bound to a locator.
FIND searches from an offset for a substring of an LOB which is bound to a locator, and returns its position. The length of a character-like substring that can be found using FIND is limited to 1333 characters. The length of a binary substring is 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 substring specified using offset and length, of a CLOB which is bound to a locator.

Methods in Binary Locators
GET_BYTES returns the substring, specified using offset and length, of a BLOB which is bound to a locator.

Creating Locators for LOBs
A locator 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 by assigning a LOB from the result set to a reference variable for a locator in the INTO clause of the statement SELECT.
See SELECT - LOB Handles.



Latest notes:

Locators cannot be created in modifying AB-SQL statements. Locators created in a read statement can, however, be used to make changes.
NON_V5_HINTS
ABAP_HINT_END

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, it must be ensured that locators are not closed implicitly using ENDSELECT, unlike reader streams, and must be closed explicitly. Furthermore, locators are closed implicitly at the end of a database LUW.

Examples

ABAP_EXAMPLES_ABEXA
Locator, copy column
Locator, access to column content
ABAP_EXAMPLE_END