Ansicht
Dokumentation

ABENSEARCH_FUNCTIONS - SEARCH FUNCTIONS

ABENSEARCH_FUNCTIONS - SEARCH FUNCTIONS

Vendor Master (General Section)   Fill RESBD Structure from EBP Component Structure  
This documentation is copyright by SAP AG.
SAP E-Book

- find, find_...

1. ... find( val = text ${ sub = substring$}$|${ pcre = regex$} $[case = case$]
           $[ off = off$] $[ len = len$] $[occ = occ$] ) ...

2. ... find_end( val = text ${ sub = substring$}$|${ pcre = regex$} $[case = case$]
               $[ off = off$] $[ len = len$] $[occ = occ$] ) ...

3. ... find_any_of( val = text sub = substring
                  $[ off = off$] $[ len = len$] $[occ = occ$] ) ...

4. ... find_any_not_of( val = text  sub = substring
                      $[off = off$] $[ len = len$] $[occ = occ$] ) ...


Effect

The built-in search functions find and find_... search text for the characters specified in substring or for a match with a regular expression specified in regex, where the optional parameters off and len determine the subarea to be searched and the occurrence of the match can be specified in the optional parameter occ.

If the argument pcre is used, regex must contain a PCRE regular expression. A regular expression in PCRE 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 # into a pattern, they must be escaped or the extended mode must be switched of with (?-x) in the regular expression.

The return value has the type i and is filled as follows:

  • The function find searches for the exact substring specified in substring or for a match with the regular expression regex and returns the offset of the occurrence with respect to the entire length of text. The search is case-sensitive by default, but this can be overridden using the parameter case. If substring is empty, an exception from the class CX_SY_STRG_PAR_VAL is raised.
  • The function find_end searches like find, but it returns the sum of the offset of the occurrence and the length of the found match with the regular expression.
  • The function find_any_of returns the offset of the occurrence of any character contained in substring, and is always case-sensitive. If substring is empty, the value -1 is returned.
  • The function find_any_not_of returns the offset of the found occurrence of any character not in substring, and is always case-sensitive. If substring is empty, the value -1 is returned.

If a search is not successful, all functions return the value -1.

The optional parameters off, len, and occ have the following meaning when combined:

  • If occ is positive, the subarea defined by off and len is searched from left to right.
  • If occ is negative, the subarea defined by off and len is searched from right to left.

The occurrence of the match specified by occ refers to the search range defined by off and len.

Notes

  • Using the related search functions count and count_..., it is possible to determine the total number of occurrences instead of an offset.
  • Like the statement FIND, the search functions can be faster than the comparison operator CS by some magnitude.

The result of the following function calls is 3, 6, 3, and 3.

String Functions, find and substring

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: Substring in sub or regular expression in regex is empty or occurrence in occ is 0.
    Runtime Error: STRG_ILLEGAL_PAR





TXBHW - Original Tax Base Amount in Local Currency   ROGBILLS - Synchronize billing plans  
This documentation is copyright by SAP AG.

Length: 9390 Date: 20240424 Time: 090232     sap01-206 ( 105 ms )