Skip to Content
0
Jan 04, 2023 at 06:33 PM

'SWA_STRING_SPLIT' splitting problem.

205 Views

I'm using the FM 'SWA_STRING_SPLIT' to split a string of 255.
While debugging I noticed that it doesn't split at the maximum of length that I gave, but instead like in the screenshot I attached.
What I'm trying to do is to split the first part when reach length 128 (the limit length of ALV) and insert it into field HEADER1, and the rest of the string into field HEADER1_SPLIT.

I can actually add another field to show the rest of the string, but I prefer to keep just 2.

image.png

LOOP AT gt_out.
CALL FUNCTION 'SWA_STRING_SPLIT'
EXPORTING
input_string = lv_testo1
max_component_length = 128
* TERMINATING_SEPARATORS =
* OPENING_SEPARATORS =
TABLES
string_components = it_split1
EXCEPTIONS
max_component_length_invalid = 1
OTHERS = 2.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.

LOOP AT it_split1.
READ TABLE it_split1 INDEX 1.
IF sy-subrc IS INITIAL.
gt_out-header1 = it_split1-str.
ENDIF.

READ TABLE it_split1 INDEX 2.
IF sy-subrc IS INITIAL.
gt_out-header1_split = it_split1-str.
ENDIF.

ENDLOOP.
*
MODIFY gt_out.

Attachments

image.png (24.8 kB)