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 loop is executed, the result is in result
"X X X X X".
DATA result TYPE string VALUE `XXXXX`.
DO strlen( result ) - 1 TIMES.
result = insert( val = result sub = ` ` off = sy-index * 2 - 1 ).
ENDDO.
Exceptions
Catchable Exceptions
CX_SY_RANGE_OUT_OF_BOUNDS
-
Cause: Invalid offset specified in
places
.
Runtime Error:STRING_OFFSET_TOO_LARGE