Ansicht
Dokumentation

ABENCONTAINS_FUNCTIONS - CONTAINS FUNCTIONS

ABENCONTAINS_FUNCTIONS - CONTAINS FUNCTIONS

ABAP Short Reference   Vendor Master (General Section)  
This documentation is copyright by SAP AG.
SAP E-Book

- contains, contains_...

1. ... contains( val = text sub$|start$|end = substring $[case = case$]
                $[ off = off$] $[len = len$] $[occ = occ$] ) ...

2. ... contains( val = text pcre$|xpath = regex $[case = case$]
                $[ off = off$] $[len = len$] $[occ = occ$] ) ...

3. ... contains_any_of( val = text sub$|start$|end = substring
                       $[off = off$] $[len = len$] $[occ = occ$] ) ...

4. ... contains_any_not_of( val = text sub$|start$|end = substring
                           $[ off = off$] $[len = len$] $[occ = occ$] ) ...


Effect

These built-in predicate functions return a truth value for a condition to the argument text.

  • The variants of the function contains with the parameters sub, start, or end scan a search range defined by off and len in text for matches with the string specified in substring. The return value is true if at least the number of matches specified in occ is found. The search is case-sensitive by default, but this can be overridden using the parameter case. If substring is passed to start or end, the matches must occur directly one after another either at the start or at the end of the search range. sub, on the other hand, allows the matches to occur anywhere in the search range. If substring is empty, an exception of the class CX_SY_STRG_PAR_VAL is raised.

A regular expression in PCRE or XPath syntax is compiled in an extended mode: Most unescaped whitespace (blanks and line breaks) of the pattern are ignored outside character classes and comments can be placed behind #. In order to include whitespace and # in a pattern, they must be escaped or the extended mode must be switched of with (?-x) in the regular expression.
The return value is true if at least the number of matches specified in occ is found. The search is case-sensitive by default, but this can be overridden using the parameter case.
  • The function contains_any_of has the same effect as contains, but does not check for the occurrences of the entire string in substring. Instead, it checks for the individual characters in substring, which is always case-sensitive. The return value is true if text contains at least the set of characters specified in occ. If start or end are specified, the characters must be at the start or at the end of the search range in any order, whereas in sub they can be anywhere.
  • The function contains_any_not_of has the same effect as contains_any_of but does not require the characters from substring. Instead, it requires any characters that are not in substring.

occ is a numeric expression position of type i and its default value is 1. Specifying a value less than or equal to 0 raises an exception of the class CX_SY_STRG_PAR_VAL.

Notes

  • The parameter occ has a different meaning here than in other functions used for searches.

Example

The IF block is reached in the following code section, since neither the first nor the last character in html occur in the system field sy-abcde.

Example

The following function call checks whether a type c field contains any non-digit character.

Exceptions

Catchable Exceptions

CX_SY_RANGE_OUT_OF_BOUNDS

  • Cause: Illegal offset or length specified in off and len.
    Runtime Error: STRING_OFFSET_TOO_LARGE

CX_SY_REGEX_TOO_COMPLEX

CX_SY_STRG_PAR_VAL

  • Cause: A substring in substring or regular expression in regex is empty or the number of occurrences in occ is less than or equal to 0.
    Runtime Error: STRG_ILLEGAL_PAR





BAL Application Log Documentation   CL_GUI_FRONTEND_SERVICES - Frontend Services  
This documentation is copyright by SAP AG.

Length: 9506 Date: 20240425 Time: 141850     sap01-206 ( 129 ms )