CX_SY_REPLACE_INFINITE_LOOP is raised in this case.
If regex contains a regular
expression in the pattern , and
this expression matches the empty character string, then the content of
new is also inserted before the first character when the first
occurrence is being searched for. If all occurrences are being searched
for, the content of new is inserted in front of the first
character, in all spaces that do not come before or inside a match, and
after the last character.
Latest notes: If the addition ALL OCCURRENCES is used, no
recursions take place. This means that, if the statement finds further
occurrences of the search pattern, they are not replaced automatically,
since this could create endless loops.
Example ABAP Coding After being replaced, text contains the value
"x-xx-x".
DATA text TYPE string VALUE '-uu-'.
REPLACE ALL OCCURRENCES OF REGEX 'u*' IN text WITH 'x'.
Example ABAP Coding After being replaced, text still contains the
substring "abcde" once.
DATA text TYPE string VALUE 'xxababcdcdxx'.
REPLACE ALL OCCURRENCES OF 'abcd' IN text WITH ``.
ABAP_ADDITION_2 ... IN {CHARACTER|BYTE} MODE
What does it do? The optional IN {CHARACTER|BYTE} MODE addition
determines whether character
string or byte string processing is carried out. If the addition is
not specified, character string processing is carried out. Depending on
the processing type, dobj , new , and substring in
pattern have to be character-like or
byte-like. If regular expressions
are used in pattern , only character string processing is
permitted.
Latest notes: To be replaced by character-like content that contains
trailing blanks, new has to have the data type string .
Runtime Exceptions
Catchable Exceptions
CX_SY_REPLACE_INFINITE_LOOP
Reason for error: Substring of length 0 generates an endless loop
when searching for all occurrences.
Runtime error: REPLACE_INFINITE_LOOP
CX_SY_INVALID_REGEX
Reason for error: Illegal expression after the addition REGEX .
Runtime error: INVALID_REGEX
CX_SY_REGEX_TOO_COMPLEX
Reason for error: More information: Exceptions
in Regular Expressions .
Runtime error: REGEX_TOO_COMPLEX
CX_SY_INVALID_REGEX_FORMAT
Reason for error: Invalid replacement pattern
after the addition WITH .
Runtime error: INVALID_FORMAT
Documentation extract taken from SAP system, � Copyright SAP AG. All rights reserved