Skip to content

ABAP Keyword Documentation →  ABAP - Reference →  Processing External Data →  ABAP - Database Accesses →  Open SQL →  Open SQL - Read Accesses →  SELECT →  SELECT - cond →  WHERE - sql_cond 

sql_cond - LIKE

Other versions: 7.31 | 7.40 | 7.54


... col [NOT] LIKE dobj [ESCAPE esc] ...


This expression is true if the value of the column col fits (does not fit) the pattern in the data object dobj. It is not possible to specify a column ID for dobj. The data types of the column col and the data object dobj must be character-type.

Wildcard characters can be used to create the pattern in dobj, where "%" represents any character string, even an empty one, and "_" represents any character. Captilatization is taken into account. Blank characters at the end of dobj are ignored. This is also valid in particular for data objects of the type string with closing blank characters that are otherwise taken into account in ABAP.

With the addition ESCAPE, an escape character can be defined. esc must be a flat character-like data object of the length 1, the content of which is used as an escape character. esc is always accessed like a data object of the data type c of the length 1. An escape character may only be placed before a wildcard character or before the escape character itself. In this case, they lose their special meaning. The addition ESCAPE cannot be used when accessing pooled tables.


  • The use of the wildcard characters "_" and "%" corresponds to the standard of SQL. In the rest of ABAP, the wildcard characters "+" and "*" are used in similar logical expressions, in particular when selection tables are used.

  • You should not use patterns that are closed by wildcard characters to search for closing blanks.

The semantics of searches of this type are dependent on the database system that is used and in general do not lead to the desired result.


Full-text search in a text table.


DATA text_tab TYPE TABLE OF doktl. 

srch_str = '%' && srch_str && '%'. 

       FROM doktl 
       INTO TABLE text_tab 
       WHERE doktext LIKE srch_str.


To search for the template '100%', the following expression can be used with # as the escape character.

... LIKE '100#%' ESCAPE '#' ...