SAP INSERT FUNCTIONS SAP Info












ARTICLE ( Version: 0021)

• insert ABAP_FUNCTION ( Version: 0021)

insert - Insert Function

Syntax
... insert( val = text sub = substring [off = off] ) ...


Effect
This function inserts the character string specified in substring
in the character string specified in text at the offset specified in off and returns the result. The default value of off is 0.
text and substring are
character-like expression positions. If they have a fixed length, trailing blanks are ignored. If the value of off is negative or not in text, an exception of the class CX_SY_RANGE_OUT_OF_BOUNDS is raised. The optional addition off is a numerical expression position .



Example
After execution of the following loop, 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.

ARTICLE ( Version: 0032)

• insert ABAP_FUNCTION ( Version: 0032)

insert - Insert Function

Syntax
... insert( val = text
sub = substring [ off = off] ) ...

Effect
This function inserts the character string specified in
substring before the first character and at the optional offset specified in off into the character string specified in text and returns the lengthened result.

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.

ARTICLE ( Version: 0036)

• insert ABAP_FUNCTION ( Version: 0036)

insert - Insert Function

Syntax
... insert( val = text
sub = substring [ off = off] ) ...

Effect
This function inserts the character string specified in
substring before the first character and at the optional offset specified in off into the character string specified in text and returns the lengthened result. If substring is empty, the unchanged content of text is returned.

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.



Runtime Exceptions

Catchable Exceptions
CX_SY_RANGE_OUT_OF_BOUNDS
Reason for error:
Unreliable offset entry in off.
Runtime error:
STRING_OFFSET_TOO_LARGE (catchable)

ARTICLE ( Version: 0037)

• insert ABAP_FUNCTION ( Version: 0037)

insert - Insert Function

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.



Runtime Exceptions

Catchable Exceptions
CX_SY_RANGE_OUT_OF_BOUNDS
Reason for error:
Invalid offset specified in places.
Runtime error:
STRING_OFFSET_TOO_LARGE (catchable)

ARTICLE ( Version: 0038)

• insert ABAP_FUNCTION ( Version: 0038)

insert - Insert Function

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.



Runtime Exceptions

Catchable Exceptions
CX_SY_RANGE_OUT_OF_BOUNDS
Reason for error:
Invalid offset specified in places.
Runtime error:
STRING_OFFSET_TOO_LARGE

ARTICLE ( Version: 0039)

• insert ABAP_FUNCTION ( Version: 0039)

insert - Insert Function

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.



Runtime Exceptions

Catchable Exceptions
CX_SY_RANGE_OUT_OF_BOUNDS
Reason for error:
Invalid offset specified in places.
Runtime error:
STRING_OFFSET_TOO_LARGE
Message text extract from SAP system. Copyright SAP SE.


Search for further information about these or an SAP related objects



Comments on this SAP object

What made you want to lookup this SAP object? Please tell us what you were looking for and anything you would like to be included on this page!