I'm dealing with a simple task on text strings.
Showing it with an example: please consider that:
tb_text_unroll is a table with many fields; the relevant fact is that TDLINE field has type "STRING".
itab_tdline is a table containing just a field, TDLINE, which is a CHAR of length 132.
Here's a sketch of code:
LOOP AT tb_text_unroll INTO wa_text_unroll.
SPLIT wa_text_unroll-TDLINE AT CL_ABAP_CHAR_UTILITIES=>NEWLINE INTO TABLE itab_tdline.
CL_ABAP_CHAR_UTILITIES=>NEWLINE is a separator which is often represented in char strings ad a sharp (#).
The problem is this: if wa_text_unroll-TDLINE contains a string which is longer than 132 chars AND the # separator follows that 132nd position, the string isn't correctly splitted into the table.
In example, strings like
"This is a short example of text which will not be correctly splitted as the next separator occours only after the 132nd position, and this leads to the odd behaviour described above.#How can I solve it?#Thanks."
will be splitted in the following three rows of itab_tdline:
This is a short example of text which will not be correctly splitted as the next separator occours only after the 132nd
How can I solve it?
as you can see, a part of the string, from the 133rd position to the separator, is lost.
Is there a way to consider multiple separators on the SPLIT clause? Something like "split at NewLine OR if the string exceed 132 chars" ?
Of course there should be many workarounds, like doing a multiple split in sequence, anyway I'd like to know what's the best solution in your opinion.
Thanks in advance,