[ABAP] TextEdit Control (cl_gui_textedit) in einem cl_gui_docking_container verwenden

Variante 1 (feste Zeilenlänge)

* Textlänge 1024 Zeichen
CONSTANTS: c_textlength TYPE i VALUE 1024.

TYPES: ty_edit_text TYPE c LENGTH c_textlength.

DATA: o_edit TYPE REF TO cl_gui_textedit.
DATA: o_dock TYPE REF TO cl_gui_docking_container.

DATA: it_tab TYPE STANDARD TABLE OF ty_edit_text.

START-OF-SELECTION.

* Testtext
  WRITE: / 'Zeile 1'.
  WRITE: / 'Zeile 2'.
  WRITE: / 'Zeile 3'.

* Container-Objekt erzeugen
  o_dock = NEW #( no_autodef_progid_dynnr = abap_true
                  side = cl_gui_docking_container=>dock_at_bottom
                  ratio = 50 ).

* Editorobjekt erzeugen wordwrap an fester Position
  o_edit = NEW #( wordwrap_mode = cl_gui_textedit=>wordwrap_at_fixed_position
                  wordwrap_position = c_textlength
                  parent = o_dock ).

* feste Zeichenbreite
  o_edit->set_font_fixed( mode = cl_gui_textedit=>true ).

AT LINE-SELECTION.
* bei Doppelklick auf Zeile
  IF o_edit IS BOUND.
* Text aus dem Editor holen
    o_edit->get_text_as_r3table( IMPORTING table = it_tab ).
* akt. gewählte Zeile anfügen
    APPEND sy-lisel TO it_tab.
* Text wieder im Editor anzeigen
    o_edit->set_text_as_r3table( table = it_tab ).
  ENDIF.

Variante 2 (variable Zeilenlänge)

DATA: o_edit TYPE REF TO cl_gui_textedit.
DATA: o_dock TYPE REF TO cl_gui_docking_container.

DATA: it_tab TYPE STANDARD TABLE OF char1024.

START-OF-SELECTION.

* Testtext
  WRITE: / 'Zeile 1'.
  WRITE: / 'Zeile 2'.
  WRITE: / 'Zeile 3'.

* Container-Objekt erzeugen
  o_dock = NEW #( no_autodef_progid_dynnr = abap_true
                  side = cl_gui_docking_container=>dock_at_bottom
                  ratio = 50 ).

* Editorobjekt erzeugen wordwrap an fester Position
  o_edit = NEW #( wordwrap_mode = cl_gui_textedit=>wordwrap_at_windowborder
                  wordwrap_to_linebreak_mode = cl_gui_textedit=>true
                  parent = o_dock ).

* feste Zeichenbreite
  o_edit->set_font_fixed( mode = cl_gui_textedit=>true ).

AT LINE-SELECTION.
* bei Doppelklick auf Zeile
  IF o_edit IS BOUND.
* Text aus dem Editor holen
    o_edit->get_text_as_stream( IMPORTING text = it_tab ).
* akt. gewählte Zeile anfügen
    APPEND sy-lisel TO it_tab.
* Text wieder im Editor anzeigen
    o_edit->set_text_as_stream( text = it_tab ).
  ENDIF.