Ansicht
Dokumentation
ABENWHERE_LOGEXP_LIKE - WHERE LOGEXP LIKE
BAL Application Log Documentation Addresses (Business Address Services)This documentation is copyright by SAP AG.
- LIKE
... operand1 $[NOT$] LIKE operand2 $[ESCAPE esc$] ...
Addition:
Effect
This relational expression is true if the value of the operand operand1 matches (does not match) the pattern in the operand operand2.
- The following applies to operand1:
- SQL expressions except for aggregate expressions and window expressions can be specified.
- The data type of can be one of the character-like dictionary types CHAR, NUMC, CLNT, LANG, DATS, TIMS, ACCP, CUKY, UNIT, or SSTRING.
- In a HAVING clause, aggregate expressions can also be used.
- The following applies to operand2:
- Literals and host variables can be specified.
- Any trailing blanks are ignored by the pattern, even in the data type string.
- The content can be a maximum of twice the number of characters in the length of operand1, but no more than 1333 characters. Character literals and constants, however, respect any trailing blanks and a syntax error occurs if this rule is broken. All other data objects ignore trailing blanks and a runtime error occurs if this rule is broken.
- The content of untyped literals and host variables must match the data type of operand1 in accordance with the rules for lossless assignments. This is checked by the strict modes of the syntax check from Release and can raise an exception.
A pattern in operand2 is defined using the following wildcard characters:
- "%" is any character string, including an empty string
- "_" stands for any character.
The pattern is case-sensitive. If the pattern in operand2 consists of exactly one "%" character, the evaluation of the condition in the database interface is optimized so that the condition is not passed to the database and operand1 LIKE '%' is always true regardless of the content of operand1 and operand1 NOT LIKE '%' is always false instead.
Notes
- The wildcard characters "_" and "%" are used as in standard SQL. Elsewhere in ABAP, the wildcard characters "+" and "*" are used in similar relational expressions, in particular when ranges table are used.
- It is not usually beneficial to define patterns in operand2 without wildcard characters. Instead, it is best to perform a comparison using =.
- Patterns that are closed by wildcard characters should not be used to search for trailing blanks. The semantics of searches of this type depend on the database system that is used and in general do not produce the required result.
- Due to -specific optimization, operand1 LIKE '%' is also true if the operand operand1 contains null values.
- No columns col and no host expressions can be specified here on the right side.
- That trailing blanks in operand2 are also ignored for the data type string is different to all other operand positions in ABAP.
- The special character-like types n, d, and t cannot be used on the right side, since the wildcard characters "_" and "%" required for patterns are invalid content for these types.
- The maximum number of characters on the right side is twice the maximum in operand1 because, in theory, each character can be prefixed with an escape character defined using ESCAPE.
Example
Full text search in a table with text columns.
Example
Pattern comparison for a numeric column of the table DEMO_EXPRESSIONS. A CAST expression is used here to create the required character-like data type.
Addition
... ESCAPE esc.
Effect
The addition ESCAPE can be used to define a single-character escape character. esc expects a flat character-like data object with the length 1 containing the escape character. A literal or a host variable can be specified. In the pattern in operand2, the escape character in esc may only be placed in front of a wildcard character or the escape character itself. In this case, they lose their special meaning.
If an escape character in operand2 is not placed in front of a valid character, an exception of the class CX_SY_OPEN_SQL_DB is raised.
Notes
- The character # is recommended for the escape character esc.
- One of the wildcard characters "_" and "%" can be specified as an escape character esc, but is not recommended for reasons of readability.
- If the pattern in operand2 is created dynamically or comes from outside of the program, it must be ensured that any escape characters it contains are not placed in front of characters other than "_", "%", or the escape character itself. To prevent the corresponding exception, escape characters that are part of the pattern must be escaped by themselves before being used.
Example
To search for the pattern '100%', the following expression can be used with # as the escape character.
... LIKE '100#%' ESCAPE '#' ...
TXBHW - Original Tax Base Amount in Local Currency rdisp/max_wprun_time - Maximum work process run time
This documentation is copyright by SAP AG.
Length: 8901 Date: 20240328 Time: 093029 sap01-206 ( 120 ms )