Code: Alles auswählen.
form split_text
using ud_text TYPE csequence
changing ct_table TYPE table
cd_length TYPE any. "Eigentlich optional
DATA:
ld_length TYPE i,
ld_text TYPE string.
FIELD-SYMBOLS:
<la_line> TYPE any.
REFRESH ct_table.
APPEND INITIAL LINE TO ct_table ASSIGNING <la_line>
DESCRIBE FIELD <la_line> LENGTH ld_length IN CHARACTER MODE.
ld_text = ud_text.
REFRESH ct_table.
WHILE ld_text IS NOT INITIAL.
APPEND INITIAL LINE TO ct_table ASSIGNING <la_line>.
<la_line> = ld_text.
SHIFT ld_text BY ld_length PLACES LEFT IN CHARACTER MODE.
ENDWHILE.
cd_length = strlen( ud_text ).
ENDFORM.
Code: Alles auswählen.
FORM concatenate_text
USING ut_table TYPE TABLE
CHANGING cd_text TYPE csequence
cd_length TYPE any. "Eigentlich optional
DATA:
ld_lines TYPE i,
ld_length TYPE i,
ld_text TYPE xstring.
FIELD-SYMBOLS:
<la_line> TYPE any.
CLEAR cd_text.
CLEAR cd_length.
ld_lines = lines( ut_table ).
READ TABLE ut_table ASSIGNING <la_line> INDEX ld_lines.
IF sy-subrc EQ 0.
DESCRIBE FIELD <la_line> LENGTH ld_length IN CHARACTER MODE.
ld_length = ( ld_length * ( ld_lines - 1 ) ) + strlen( <la_line> ).
ENDIF.
CONCATENATE LINES OF ut_table INTO ld_text IN CHARACTER MODE.
* Ganz wichtig, damit der String die richtige Länge hat
cd_text = ld_text(ld_length).
cd_length = ld_length.
ENDFORM.
Folgende Benutzer bedankten sich beim Autor a-dead-trousers für den Beitrag:
Stephan-KKH