What does it do? The operand dobj> is searched for the character or byte sequence determined by a search pattern pattern>>. The additions FIRST OCCURRENCE> and ALL OCCURRENCES> determine whether all occurrences or only the first one is searched. The addition section_of>> can be used to restrict the search range. The search is terminated if the search pattern is found for the first time, all search patterns in the entire search range have been found, or if the end of the search range was reached. The search result is communicated by setting sy-subrc>. The addition MODE> determines whether a character or byte string is processed, and the addition find_options> > provides additional options for controlling and evaluating the statement. When a character string is processed, dobj> is a character-like expression position> and the blanks are respected for dobj> operands of a fixed length. System Fields> sy-subrc>Meaning> 0The search pattern was found at least once in the search range. 4The search pattern was not found in the search range. BEGIN_SECTION SAP_INTERNAL_HINT The former value 8 for illegal double byte characters is not set any more since only Unicode is supported now. END_SECTION SAP_INTERNAL_HINT
Latest notes:
The statement FIND IN TABLE>> is available for searching in internal tables.
Search functions> can be used to search in a string in an operand position. They cover some of the functions of the statement FIND>.
The statement FIND> and the search functions can be quicker than the comparison operator CS>> by some magnitude. NON_V5_HINTS ABAP_HINT_END
ABAP_EXAMPLE_VX5 The simplest form of the statement FIND>. ABEXA 00265 ABAP_EXAMPLE_END • FIRST OCCURRENCE OF FIND • ALL OCCURRENCES OF FIND
ABAP Addition >
What does it do? The optional addition ${FIRST OCCURRENCE$}$|${ALL OCCURRENCES$} OF > specifies whether all or only the first occurrence of the search pattern is searched. If the addition FIRST OCCURRENCE> or none of the additions is specified, only the first occurrence is searched for. Otherwise, all occurrences are searched for. If substring> is an empty string in pattern>> or is of type c>, n>, d>, or t > and only contains blanks, the place in front of the first character or byte of the search range is found when searching for the first occurrence. In searches for all occurrences, the exception CX_SY_FIND_INFINITE_LOOP> is raised in this case. If regex> in pattern> contains a regular expression >> that matches the empty character string, the search for the first occurrence also finds the place in front of the first character. When searching for all occurrences in this case, the search finds the place in front of the first character, all interim places that are not within a match, and the place after the last character.
ABAP_EXAMPLE_VX5 All three occurrences of the letter a> are searched for and found. ABEXA 00266 ABAP_EXAMPLE_END • IN BYTE MODE FIND • IN CHARACTER MODE FIND
ABAP Addition
What does it do? The optional addition IN ${CHARACTER$|BYTE$} MODE> determines whether character string or byte string processing> is performed. If the addition is not specified, character string processing is performed. Depending on the processing type, dobj> and substring> in pattern>> must be character-like or byte-like. If regular expressions> are used in pattern>, only character string processing is allowed.
ABAP_EXAMPLE_VX5 Search for the first byte that represents a blank space in the code page UTF-8. ABEXA 00267 ABAP_EXAMPLE_END
Runtime Exceptions
Catchable Exceptions CX_SY_FIND_INFINITE_LOOP>>
Reason for error:
Substring of length 0> creates an endless loop when searching for all occurrences.
Runtime error:
FIND_INFINITE_LOOP> CX_SY_RANGE_OUT_OF_BOUNDS>>
Reason for error:
Illegal offset or length specified in the addition SECTION OF>.
Runtime error:
REFI_WRONG_SECTION> CX_SY_INVALID_REGEX>>
Reason for error:
Invalid expression after the addition PCRE$|REGEX>.
Runtime error:
INVALID_REGEX> CX_SY_REGEX_TOO_COMPLEX>>
Reason for error:
More information: Exceptions in Regular Expressions>.