sql_cond - LIKE
... 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
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 character can be defined.
esc must be a
object of the length 1, the content of which is used as an escape character.
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
- 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.
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.
To search for the template '100%', the following expression can be used with
# as the escape character.
... LIKE '100#%' ESCAPE '#' ...