SAP WHERE LOGEXP LIKE Get Example source ABAP code based on a different SAP table
SAP Help
Short Reference > • LIKE ABAP_OSQL_COND • NOT LIKE ABAP_OSQL_COND • /pt LIKE • _ LIKE ABAP_SQLCOND > - LIKE> ABAP_SYNTAX ... operand1 $[NOT$] LIKE operand2 $[ESCAPE esc$] ...> ABAP Addition ... ESCAPE esc> What does it do? 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 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. The data type must be c>> or string>>. Any trailing blanks are ignored by the pattern, even in the data type string>. The content can have a maximum of twice as many characters as the length of operand1> but no more than 1333 characters. Character literals> and constants> 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>. BEGIN_SECTION VERSION 5 OUT This is checked by the strict modes> of the syntax check from ABAP_RELEASE ABAP_740_SP08 and can raise an exception. END_SECTION VERSION 5 OUT 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. Latest 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 AB-SQL -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. The fact 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>. BEGIN_SECTION SAP_INTERNAL_HINT The optimization for LIKE '%'> produces different results in AB_SQL compared to platform-specific SQL that follows the SQL standard. In standard SQL, LIKE '%'> is false for null values, but true in AB_SQL . END_SECTION SAP_INTERNAL_HINT NON_V5_HINTS ABAP_HINT_END ABAP_EXAMPLE_VX5 Full text search in a table with text columns. ABEXA 01403 ABAP_EXAMPLE_END ABAP_EXAMPLE_VX5 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. ABEXA 01404 ABAP_EXAMPLE_END • ESCAPE ABAP_OSQL_COND ABAP Addition What does it do? 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 in front of 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. Latest 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 it 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 no escape character contained in the pattern is placed in front of any character 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. NON_V5_HINTS ABAP_HINT_END ABAP_EXAMPLE_VX5 To search for the pattern '100%', the following expression can be used with #> as the escape character. ... LIKE '100#%' ESCAPE '#' ...> ABAP_EXAMPLE_END