[ABAP] Daten aus der Zwischenablage (Clipboard) importieren

* Datentyp mit ausreichend Länge für Zeilen der Clipboard-Daten
TYPES: ty_char4096 TYPE c LENGTH 4096.

DATA: it_clipboarddata TYPE STANDARD TABLE OF ty_char4096.
DATA: it_splitelements TYPE STANDARD TABLE OF string.
DATA: lv_line_count TYPE i.

cl_gui_frontend_services=>clipboard_import( IMPORTING
                                              data                 = it_clipboarddata
                                              length               = lv_line_count
                                            EXCEPTIONS
                                              cntl_error           = 1
                                              error_no_gui         = 2
                                              not_supported_by_gui = 3
                                              OTHERS               = 4 ).

IF sy-subrc = 0.
  WRITE: / 'Zeilen:', lv_line_count.

  SKIP.

* Zeilen der Clipboarddaten durchloopen
  LOOP AT it_clipboarddata ASSIGNING FIELD-SYMBOL(<fs_line>).

* die Zeilen am TAB spaltenweise aufsplitten
    SPLIT <fs_line> AT cl_abap_char_utilities=>horizontal_tab INTO TABLE it_splitelements.

* Zeilendaten verarbeiten -> neu zusammenbauen
    DATA(lv_line) = ||.

    LOOP AT it_splitelements ASSIGNING FIELD-SYMBOL(<fs_elem>).
      IF lv_line IS INITIAL.
        lv_line = <fs_elem>.
      ELSE.
        lv_line = |{ lv_line }\|{ <fs_elem> }|.
      ENDIF.
    ENDLOOP.

* Ausgabe
    WRITE: / lv_line.
  ENDLOOP.
ENDIF.