Ansicht
Dokumentation

STRING_SPLIT - (Obsolete) Split a string in accordance with a delimiter.

STRING_SPLIT - (Obsolete) Split a string in accordance with a delimiter.

rdisp/max_wprun_time - Maximum work process run time   BAL_S_LOG - Application Log: Log header data  
This documentation is copyright by SAP AG.
SAP E-Book
Functionality

STRING_SPLIT splits STRING according to the delimiter sequence DELIMITER into two parts, HEAD and TAIL:

- HEAD contains the initial part of STRING, ending with the last character before the first occurrence of DELIMITER.

- TAIL contains the end of STRING, beginning with the first character after the first occurrence of DELIMITER.

The character string passed on in DELIMITER is interpreted as a delimiter sequence until the first blank (uppercase/lowercase notation is taken into account). If the blank character is to be part of the delimiter sequence, it must be preceded by the escape symbol '#'. If the escape symbol is to be part of the delimiter sequence, '##' must be entered.

There are four exceptions:

- NOT_FOUND occurs when DELIMITER does not occur in STRING.

- NOT_VALID occurs when DELIMITER ends with one single escape symbol '#'.

- TOO_LONG occurs when the actually used length of the parameter assigned to DELIMITER is more than 40 characters.

- TOO_SMALL occurs when at least one of the two parameters passed on to HEAD and TAIL is too short.

All exceptions are generated with RAISE and must be handled in the calling program.

Examples


STRING = ' abc-de fg*#hij '
DELIMITER = 'c-de# fg*##h'
HEAD = ' ab' and TAIL = 'ij '.

Sample call:

DATA: STR(40), DEL(10), H(30), T(30).

MOVE 'abcdefghijklmnopqrstuvwxyz' TO STR.

MOVE 'klmnop' TO DEL.

CALL FUNCTION 'STRING_SPLIT`

EXPORTING STRING = STR

DELIMITER = DEL

IMPORTING HEAD = H

TAIL = T

EXCEPTIONS NOT_FOUND = 1

NOT_VALID = 2

TOO_LONG = 3

TOO_SMALL = 4.

CASE SY-SUBRC.

WHEN '0'.

* Initial part is in H, end in T

WHEN '1'.

* DEL is not included in STR.

WHEN '2'.

* DEL is not valid (single escape symbol '#' at the end)

WHEN '3'.

* DEL is too long (longer than 40 characters)

WHEN '4'.

* The actual parameter H or T is too short.

ENDCASE.

Note

The ABAP/4 language element SPLIT string AT delimiter INTO head tail provides the same functionality as the function module. Only the exceptions are handled differently. Also refer to the ABAP/4 documentation for SPLIT.

The ABAP/4 language element provides better performance than the function module call.

The function module has been retained to ensure compatibility with future releases.





Parameters

DELIMITER
HEAD
STRING
TAIL

Exceptions

NOT_FOUND
NOT_VALID
TOO_LONG
TOO_SMALL

Function Group

CSTR

CPI1466 during Backup   BAL_S_LOG - Application Log: Log header data  
This documentation is copyright by SAP AG.

Length: 3976 Date: 20240523 Time: 101246     sap01-206 ( 27 ms )