ABAP Keyword Documentation → ABAP − Reference → Processing Internal Data → Character String and Byte String Processing → Expressions and Functions for String Processing → String Functions → Processing Functions for Character-Like Arguments
insert- Insert Function
Other versions: 7.31 | 7.40 | 7.54
Syntax
... insert( val = text
sub = substring [off = off] ) ...
Effect
This function inserts the character string specified in
substring in the string specified in
text, either before the first character or at the optional offset specified
off
and returns the result. If substring
is empty, the unchanged content of text
is returned.
The return code has the type string
.
Example
After the following iteration is executed, the result is in result
"X X X X X".
DATA(result) = `XXXXX`.
result =
REDUCE #( INIT r = result
FOR j = 1 UNTIL j > strlen( result ) - 1
NEXT r = insert( val = r sub = ` ` off = j * 2 - 1 ) ).
Exceptions
Handleable Exceptions
CX_SY_RANGE_OUT_OF_BOUNDS
-
Cause: Invalid offset specified in
places
.
Runtime error:STRING_OFFSET_TOO_LARGE