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

Short Reference

sql_cond - LIKE

Syntax

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

Effect

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-like.

Wildcard characters can be used to create the pattern in dobj, where "%" represents any character string, even an empty one, and "_" represents any character. It is case-sensitive. Trailing blanks in dobj are ignored. This is also valid in particular for data objects of the type string whose trailing blanks are otherwise respected in ABAP.

The addition ESCAPE can be used to define an escape character. esc must be a flat character-like data object with length one, whose content 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, these lose their special meaning. The addition ESCAPE cannot be used when reading pooled tables.

Notes

Example

Full-text search in a text table.

PARAMETERS srch_str TYPE c LENGTH 20.

DATA text_tab TYPE TABLE OF doktl.

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

SELECT *
       FROM doktl
       INTO TABLE text_tab
       WHERE doktext LIKE srch_str.

Example

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

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