SAP REPLACE - Reference ABAP Statements

Get Example source ABAP code based on a different SAP table
  


Standard SAP Help for REPLACE

REPLACE

ABAP Reference
ABAP Code Snippet


ABAP 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 rlen]}
| [RESULTS result_tab|result_wa] } }
| { SECTION [OFFSET off] [LENGTH len] OF dobj
WITH new
[IN {CHARACTER|BYTE} MODE] } }.
ABAP Code Snippet

What does it do? Replaces character- or byte strings in a character- or byte-type data object dobj or in an internal table itab with the content of new. Determination of the characters or bytes to be replaced using a search for substrings or regular expressions or by specifying the offset and length directly.

ABAP Addition {FIRST OCCURRENCE}|{ALL OCCURRENCES OF}
[SECTION [OFFSET off] [LENGTH len] OF]
Defines whether the first or all found locations are replaced with the content of data object new. You can restrict the search area to the section from the offset specified in off. The length of this offset is specified in len. {[SUBSTRING] substring} | {REGEX regex}
Defines whether a substring substring or a regular expression regex is searched for and replaced. SECTION [OFFSET off] [LENGTH len] OF
Specifies a section of dobj from the offset specified in off and the length specified in len. Either the section to be searched or the section to be replaced.
TABLE itab [FROM lin1 [OFFSET off1]] [TOlin2 [OFFSET off2]]
Replacement in an internal itab with restriction of the search area to the section as of the row specified in lin1 with the offset specified in off1 up to the row specified in lin2 with the offset specified in off2.
IN {CHARACTER|BYTE} MODE
Determines character- or byte string processing.
{RESPECTING|IGNORING} CASE
Determines whether uppercase/lowercase is respected during the search.
REPLACEMENT COUNT rcnt
Provides the number count of replacements in rcnt.
REPLACEMENT LINE rlin
Provides the table row of the last replacement in rlin.
REPLACEMENT OFFSET roff
Provides the offset of the last replacement in roff.
REPLACEMENT LENGTH rlen
Provides the length of the last replacement in rlen.
RESULTS result_tab|result_wa
Provides the attributes of all replaced parts or the last replaced part in an internal table result_tab or a structure result_wa of type MATCH_RESULTS.

Return to menu