ABAP Keyword Documentation → ABAP - Quick Reference
REPLACE - Quick reference
Other versions: 7.31 | 7.40 | 7.54
Syntax
REPLACE { { [{FIRST OCCURRENCE}|{ALL OCCURRENCES OF}]
{[SUBSTRING] substring} | {REGEX regex} IN
{ {[SECTION [OFFSET off] [LENGTH len] OF] dobj}
| {TABLE itab [FROM lin1 [OFFSET off1]]
[TO lin2 [OFFSET off2]]} }
WITH new
[IN {CHARACTER|BYTE} MODE]
[{RESPECTING|IGNORING} CASE]
[REPLACEMENT COUNT rcnt]
{ {[REPLACEMENT OFFSET roff]
[REPLACEMENT LENGTH rlen]
[REPLACEMENT LINE rlin]}
| [RESULTS result_tab|result_wa] } }
| { SECTION [OFFSET off] [LENGTH len] OF dobj
WITH new
[IN {CHARACTER|BYTE} MODE] } }.
Effect
Replaces character strings or byte strings in a character-like or byte-like data object dobj
or in an internal table itab
with the content of new
.
Determines the characters or bytes to be replaced using a search for substrings or regular expressions or by specifying the offset and length directly.
Additions
-
{FIRST OCCURRENCE}| {ALL OCCURRENCES OF}
Defines whether the first occurrence found or all occurrences found are replaced with the content of the data objectnew
. -
{[SUBSTRING] substring} | {REGEX regex}
Defines whether asubstring
or a regular expressionregex
is searched for and replaced. -
SECTION [OFFSET off] [LENGTH len] OF
Specifies a section ofdobj
from the offset specified inoff
and the length specified inlen
. Either the section to be searched or the section to be replaced. -
TABLE itab [FROM lin1 [OFFSET off1]] [TO lin2 [OFFSET off2]]
In an internal tableitab
, performs replacements while restricting the search area to the section from the row specified inlin1
with the offset specified inoff1
to the row specified inlin2
with the offset specified inoff2
. -
IN {BYTE|CHARACTER} MODE
Specifies character string or byte string processing. -
{RESPECTING|IGNORING} CASE
Specifies whether the search is case-sensitive. -
REPLACEMENT COUNT rcnt
Gets the number of replacements inrcnt
. -
REPLACEMENT LINE rlin
Gets the table row of the last replacement inrlin
. -
REPLACEMENT OFFSET roff
Gets the offset of the last replacement inroff
. -
REPLACEMENT LENGTH rlen
Gets the length of the last replacement inrlen
. -
RESULTS result_tab|result_wa
Gets the attributes of all replaced positions or the last replaced position in an internal tableresult_tab
or a structureresult_wa
of type MATCH_RESULTS.