SAP NetWeaver AS ABAP Release 752, ©Copyright 2017 SAP AG. All rights reserved.
ABAP - Keyword Documentation → ABAP - Reference → Processing Internal Data → Character String and Byte String Processing → Expressions and Functions for String Processing → String Functions → Description Functions for Character-Like Arguments →find, find_... - Search Functions
Syntax Forms
1. ... find( val = text {
sub = substring}|{
regex = regex} [case = case]
[
off = off] [
len = len] [occ = occ] ) ...
2. ... find_end( val = text
regex = 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 search functions find and find_... scan text for the characters specified in substring or for a match with a regular expression specified in regex, with the scanned subarea specified in the optional parameters off and len and the occurrence of the match specified in the optional parameter occ.
The return code has the type i and is filled as follows:
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:
The occurrence of the match specified by occ refers to the search area defined by off and len.
Notes
Example
The result of the following function calls is 3, 6, 3, and 3.
DATA(result1) = find( val = `xxx123yyy` regex = `\d+` ).
DATA(result2) = find_end( val = `xxx123yyy` regex = `\d+` ).
DATA(result3) = find_any_of( val = `xxx123yyy` sub = `123` ).
DATA(result4) = find_any_not_of( val = `xxx123yyy` sub = `x` ).
Executable Example
String Functions, find and substring
Handleable Exceptions
CX_SY_RANGE_OUT_OF_BOUNDS
CX_SY_REGEX_TOO_COMPLEX
CX_SY_STRG_PAR_VAL