Code: Alles auswählen.
FORM split_byte
USING id_byte TYPE xsequence
CHANGING ct_table TYPE table
cd_length TYPE numeric. "Eigentlich optional
DATA:
ld_length TYPE i,
ld_byte TYPE xstring.
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 BYTE MODE.
ld_byte = id_byte.
REFRESH ct_table.
WHILE ld_byte IS NOT INITIAL.
APPEND INITIAL LINE TO ct_table ASSIGNING <la_line>.
<la_line> = ld_byte.
SHIFT ld_text BY ld_length PLACES LEFT IN BYTE MODE.
ENDWHILE.
cd_length = xstrlen( id_byte ).
ENDFORM.
Code: Alles auswählen.
FORM concatenate_byte
USING ut_table TYPE TABLE
CHANGING cd_byte TYPE xsequence
cd_length TYPE any. "Eigentlich optional
DATA:
ld_lines TYPE i,
ld_length TYPE i,
ld_byte TYPE xstring.
FIELD-SYMBOLS:
<la_line> TYPE any.
CLEAR cd_byte.
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 BYTE MODE.
ld_length = ( ld_length * ( ld_lines - 1 ) ) + xstrlen( <la_line> ).
ENDIF.
CONCATENATE LINES OF ut_table INTO ld_byte IN BYTE MODE.
* Ganz wichtig, damit der XString die richtige Länge hat
cd_byte = ld_byte(ld_length).
cd_length = ld_length.
ENDFORM.
Folgende Benutzer bedankten sich beim Autor a-dead-trousers für den Beitrag:
Andrzej