[ABAP] DialogBox mit Text und Auswahlbuttons anzeigen (POPUP_FOR_INTERACTION)

*'I' => ICON_MESSAGE_INFORMATION
*'W' => ICON_MESSAGE_WARNING
*'E' => ICON_MESSAGE_ERROR
*'Q' => ICON_MESSAGE_QUESTION
*'C' => ICON_MESSAGE_CRITICAL
DATA: lv_icon TYPE char1 VALUE 'C'.
DATA: lv_return TYPE char1.

* Dialog box (can be configured for various purposes)
CALL FUNCTION 'POPUP_FOR_INTERACTION'
  EXPORTING
    headline       = 'Überschrift'
    text1          = 'Text1'
    text2          = 'Text2'
    text3          = 'Text3'
*   TEXT4          = ' '
*   TEXT5          = ' '
*   TEXT6          = ' '
    ticon          = lv_icon
    button_1       = 'Ja'
    button_2       = 'Nein'
    button_3       = 'Abbruch'
  IMPORTING
    button_pressed = lv_return.

* Button-Wert: 1 - button_1, 2 - button_2 oder 3 - button_3
CASE lv_return.
  WHEN 1.
    WRITE: / 'Ja', lv_return.
  WHEN 2.
    WRITE: / 'Nein', lv_return.
  WHEN 3.
    WRITE: / 'Abbruch', lv_return.
ENDCASE.

[ABAP] Editierbares SALV-Grid (IF_SALV_GUI_OM_EXTEND_GRID_API, IF_SALV_GUI_OM_EDIT_RESTRICTED)

* Quelle: https://blogs.sap.com/2022/08/01/editable-cl_salv_table-after-release-756/
* ab SAP Release 756
* Achtung: das Ganze funktioniert nur für kleine Tabellen mit max. 5000 Zellen, siehe:
*
* Methode: CL_SALV_GUI_OM_ADAPTER_TABLE->CAN_RUN_RESTRICTED_EDIT_MODE( )
* Konstante: CV_MAX_CELLS_FOR_EDITABLE (Wert: 5000).

* Eventhandler
CLASS lcl_events DEFINITION.
  PUBLIC SECTION.
* Bezeichner der Buttons
    CONSTANTS: co_btn_edit TYPE string VALUE 'BTN_EDIT'.
    CONSTANTS: co_btn_save TYPE string VALUE 'BTN_SAVE'.

* Platzhalter für Referenz auf SALV-Grid
    CLASS-DATA: o_salv TYPE REF TO cl_salv_table.

* Eventhandler-Methode für Button-Klicks in der Toolbar des SALV-Grids
    CLASS-METHODS : on_toolbar_click FOR EVENT added_function OF cl_salv_events_table
      IMPORTING
        e_salv_function
        sender.
  PRIVATE SECTION.
* Edit-Status des SALV-Grids
    CLASS-DATA: gv_edit TYPE abap_bool VALUE abap_false.
ENDCLASS.

CLASS lcl_events IMPLEMENTATION.
  METHOD on_toolbar_click.
    IF o_salv IS BOUND.

      DATA(o_api) = o_salv->extended_grid_api( ).
      DATA(o_edit) = o_api->editable_restricted( ).

      CASE e_salv_function.

        WHEN co_btn_edit.
* Edit-Modus umschalten
          IF gv_edit = abap_false.
            gv_edit = abap_true.
          ELSE.
            gv_edit = abap_false.
          ENDIF.

          TRY.
* Spalte(n) (nicht) editierbar setzen
              o_edit->set_attributes_for_columnname( EXPORTING columnname              = 'EKGRP'
                                                               all_cells_input_enabled = gv_edit ).

              o_edit->set_attributes_for_columnname( EXPORTING columnname              = 'SMTP_ADDR'
                                                               all_cells_input_enabled = gv_edit ).
            CATCH cx_salv_not_found.
          ENDTRY.

          o_edit->validate_changed_data( ).
          o_salv->refresh( ).

        WHEN co_btn_save.
* Daten auf Validität prüfen
          DATA(lv_data_is_valid) = abap_false.

          TRY.
              o_edit->validate_changed_data( IMPORTING is_input_data_valid = lv_data_is_valid ).
              o_salv->refresh( ).
            CATCH cx_salv_not_found.
          ENDTRY.

          IF lv_data_is_valid = abap_true.
* Daten hier speichern / weiterverarbeiten
            MESSAGE co_btn_save TYPE 'I'.
          ENDIF.
      ENDCASE.
    ENDIF.
  ENDMETHOD.
ENDCLASS.

START-OF-SELECTION.

  TRY.
* Beispieldaten (Einkäufergruppen) holen
      SELECT FROM t024
        FIELDS *
        INTO TABLE @DATA(it_t024).

      IF sy-subrc = 0.
        cl_salv_table=>factory( EXPORTING r_container  = cl_gui_container=>default_screen
                                IMPORTING r_salv_table = lcl_events=>o_salv
                                CHANGING  t_table      = it_t024 ).

* Standardbuttons der SALV-Table ausblenden
        lcl_events=>o_salv->get_functions( )->set_all( abap_false ).

* Eigenen SALV-Button hinzufügen
* das Hinzufügen des Buttons funktioniert nur, wenn die SALV-Table innerhalb eines Containers (z.B. cl_gui_container=>default_screen) eingebettet ist
        lcl_events=>o_salv->get_functions( )->add_function( name = |{ lcl_events=>co_btn_edit }|
                                                            icon = |{ icon_edit_file }|
                                                            text = 'Edit'
                                                            tooltip = 'Daten editieren'
                                                            position = if_salv_c_function_position=>right_of_salv_functions ).

        lcl_events=>o_salv->get_functions( )->add_function( name = |{ lcl_events=>co_btn_save }|
                                                            icon = |{ icon_save_as_template }|
                                                            text = 'Save'
                                                            tooltip = 'Daten speichern'
                                                            position = if_salv_c_function_position=>right_of_salv_functions ).

* Eventhandler für Klicks in die Toolbar des SALV-Grids setzen
        SET HANDLER lcl_events=>on_toolbar_click FOR lcl_events=>o_salv->get_event( ).

* SALV anzeigen
        lcl_events=>o_salv->display( ).

* Toolbar der Listausgabe unterdrücken
        cl_abap_list_layout=>suppress_toolbar( ).

* Listausgabe erzwingen für Erzeugung von cl_gui_container=>default_screen
        WRITE: space.

      ENDIF.
    CATCH cx_root INTO DATA(e_txt).
      WRITE: / e_txt->get_text( ).
  ENDTRY.

[ABAP] Verschieben von Nodes per Drag & Drop innerhalb einer Baumansicht (CL_COLUMN_TREE_MODEL)

* globale Objektreferenz für Tree-Objekt
DATA: o_tree TYPE REF TO cl_column_tree_model.

* Übergabeobjekt für Drag-Drop-Events
CLASS lcl_dd_object DEFINITION.
  PUBLIC SECTION.
    METHODS: constructor
      IMPORTING
        i_drag_node_text TYPE tm_nodekey.

    METHODS: get_value
      RETURNING VALUE(rv_ret) TYPE tm_nodekey.

  PRIVATE SECTION.
    DATA: gv_drag_node_text TYPE tm_nodekey.
ENDCLASS.

CLASS lcl_dd_object IMPLEMENTATION.
  METHOD constructor.
    gv_drag_node_text = i_drag_node_text.
  ENDMETHOD.

  METHOD get_value.
    rv_ret = gv_drag_node_text.
  ENDMETHOD.
ENDCLASS.

* Demoprogramm: SAPSIMPLE_TREE_DRAG_DROP_DEMO
* http://saphelp.ucc.ovgu.de/NW750/EN/4d/88f020981740abe10000000a15822b/frameset.htm
* Eventhandler-Klasse
CLASS lcl_events DEFINITION.
  PUBLIC SECTION.

    TYPES: ty_it_events TYPE STANDARD TABLE OF cntl_simple_event WITH DEFAULT KEY.

    CLASS-METHODS: on_drag FOR EVENT drag OF cl_column_tree_model
      IMPORTING
        node_key
        item_name
        drag_drop_object
        sender.

    CLASS-METHODS: on_drop FOR EVENT drop OF cl_column_tree_model
      IMPORTING
        node_key
        drag_drop_object
        sender.

    CLASS-METHODS: on_drop_complete FOR EVENT drop_complete OF cl_column_tree_model
      IMPORTING
        node_key
        item_name
        drag_drop_object
        sender.
ENDCLASS.

CLASS lcl_events IMPLEMENTATION.
* Quell-Node
  METHOD on_drag.

* Übergabe Name der Quell-Node
    drag_drop_object->object = NEW lcl_dd_object( node_key ).

  ENDMETHOD.

* Ziel-Node
  METHOD on_drop.
    TRY.
* Holen Name der Quell-Node
        DATA(o_dd_obj) = CAST lcl_dd_object( drag_drop_object->object ).

        IF o_tree IS BOUND.
* Quell-Node an Ziel-Node umhängen
          o_tree->move_node(
                              node_key          = o_dd_obj->get_value( )
                              relative_node_key = node_key
                              relationship      = cl_tree_model=>relat_last_child
                           ).
        ENDIF.
      CATCH cx_root.
* Abbruch bei Cast-Fehler
        drag_drop_object->abort( ).
    ENDTRY.
  ENDMETHOD.

  METHOD on_drop_complete.

  ENDMETHOD.
ENDCLASS.

START-OF-SELECTION.
* Tree-Control erzeugen
* item_selection = abap_true wegen der CheckBoxen
  o_tree = NEW cl_column_tree_model( node_selection_mode   = cl_column_tree_model=>node_sel_mode_single
                                     hierarchy_column_name = 'FOLDER'
                                     hierarchy_header      = VALUE #( t_image = icon_folder
                                                                      heading = 'Beispiel'
                                                                      tooltip = 'Tooltip'
                                                                      width   = 30
                                                                    )
                                     item_selection        = abap_true
                                   ).
* Spalten hinzufügen
  o_tree->add_column( EXPORTING
                        name                = 'COL1'
                        width               = 30
                        header_text         = 'Column1' ).

  o_tree->add_column( EXPORTING
                        name                = 'COL2'
                        width               = 30
                        header_text         = 'Column2' ).

* in default_screen einbetten
  o_tree->create_tree_control( parent = cl_gui_container=>default_screen ).

* Drag-Drop-Verhalten definieren
  DATA(o_behaviour) = NEW cl_dragdrop( ).

  o_behaviour->add( EXPORTING
                      flavor = 'Filestest'
                      dragsrc = abap_true
                      droptarget = abap_true
                      effect = CONV i( cl_dragdrop=>move + cl_dragdrop=>copy )
                  ).

  DATA: lv_handle_dd TYPE i.

  o_behaviour->get_handle( IMPORTING handle = lv_handle_dd ).

* Beispielhaft Nodes und Subnodes erzeugen
  o_tree->add_node( EXPORTING
                      isfolder          = abap_true
                      node_key          = 'NODE1'
                      relative_node_key = ''
                      relationship      = cl_tree_model=>relat_last_child
                      expanded_image    = CONV tv_image( icon_folder )
                      image             = CONV tv_image( icon_folder )
                      item_table        = VALUE #( ( class     = cl_column_tree_model=>item_class_checkbox
                                                     item_name = 'FOLDER'
                                                     text      = 'Obj1'
                                                     editable  = abap_true
                                                   )
                                                 )

                      drag_drop_id      = lv_handle_dd
                  ).

  o_tree->add_node( EXPORTING
                      isfolder          = abap_true
                      node_key          = 'NODE1_1'
                      relative_node_key = 'NODE1'
                      relationship      = cl_tree_model=>relat_last_child
                      expanded_image    = CONV tv_image( icon_oo_object )
                      image             = CONV tv_image( icon_oo_object )
                      item_table        = VALUE #( ( class     = cl_column_tree_model=>item_class_link
                                                     item_name = 'FOLDER'
                                                     text      = 'Obj4'
                                                   )
                                                   ( class     = cl_column_tree_model=>item_class_text
                                                     item_name = 'COL1'
                                                     text      = 'Wert1'
                                                     style     = cl_column_tree_model=>style_intensified
                                                     font      = cl_column_tree_model=>item_font_prop
                                                   )
                                                   ( class     = cl_column_tree_model=>item_class_text
                                                     item_name = 'COL2'
                                                     text      = 'Wert2'
                                                   )
                                                 )

                      drag_drop_id      = lv_handle_dd
                  ).

  o_tree->add_node( EXPORTING
                      isfolder          = abap_true
                      node_key          = 'NODE2'
                      relative_node_key = ''
                      relationship      = cl_tree_model=>relat_last_child
                      expanded_image    = CONV tv_image( icon_folder )
                      image             = CONV tv_image( icon_folder )
                      item_table        = VALUE #( ( class     = cl_column_tree_model=>item_class_checkbox
                                                     item_name = 'FOLDER'
                                                     text      = 'Obj2'
                                                     editable  = abap_true
                                                   )
                                                 )

                      drag_drop_id      = lv_handle_dd
                  ).

  o_tree->add_node( EXPORTING
                      isfolder          = abap_true
                      node_key          = 'NODE2_1'
                      relative_node_key = 'NODE2'
                      relationship      = cl_tree_model=>relat_last_child
                      expanded_image    = CONV tv_image( icon_oo_object )
                      image             = CONV tv_image( icon_oo_object )
                      item_table        = VALUE #( ( class     = cl_column_tree_model=>item_class_button
                                                     item_name = 'FOLDER'
                                                     text      = 'Obj3'
                                                   )
                                                   ( class     = cl_column_tree_model=>item_class_text
                                                     item_name = 'COL1'
                                                     text      = 'Wert1'
                                                     style     = cl_column_tree_model=>style_inactive
                                                     font      = cl_column_tree_model=>item_font_prop
                                                   )
                                                   ( class     = cl_column_tree_model=>item_class_text
                                                     item_name = 'COL2'
                                                     text      = 'Wert2'
                                                   )
                                                 )

                      drag_drop_id      = lv_handle_dd
                  ).

* Nodes expandieren
  o_tree->expand_root_nodes( expand_subtree = abap_true
                             level_count = 10 ).

* Events registrieren
* ITEM_DOUBLE_CLICK            Doppelklick auf Item
* BUTTON_CLICK                 Drucktaste wurde gedrückt
* LINK_CLICK                   Link geklickt
* CHECKBOX_CHANGE              Zustandsänderung einer Checkbox
* ITEM_KEYPRESS                Taste wurde gedrückt, Item war selektiert
* HEADER_CLICK                 Header geklickt
* ITEM_CONTEXT_MENU_REQUEST    Anforderung eines Kontext-Menüs für ein Item
* ITEM_CONTEXT_MENU_SELECT     Kontext-Menü Eintrag wurde ausgewählt
* HEADER_CONTEXT_MENU_REQUEST  Anforderung eines Kontext-Menüs für einen Header
* HEADER_CONTEXT_MENU_SELECT   Kontext-Menü Eintrag wurde ausgewählt
* DRAG                         Ereignis zum Füllen des Drag Drop Daten - Objekts
* DRAG_MULTIPLE                Ereignis zum Füllen des Drag Drop Daten - Objekts
* DROP_COMPLETE                Ereignis nach erfolgreichem Drop
* DROP_COMPLETE_MULTIPLE       Ereignis nach erfolgreichem Drop
  SET HANDLER lcl_events=>on_drag FOR o_tree.
  SET HANDLER lcl_events=>on_drop FOR o_tree.
  SET HANDLER lcl_events=>on_drop_complete FOR o_tree.

* Erzeugung von cl_gui_container=>default_screen erzwingen
  WRITE: space.

[ABAP] Beispiel für die Verwendung von CL_COLUMN_TREE_MODEL

* Demoprogramm: SAPCOLUMN_TREE_CONTROL_DEMO
* http://saphelp.ucc.ovgu.de/NW750/EN/4d/88f020981740abe10000000a15822b/frameset.htm
* Eventhandler-Klasse
CLASS lcl_events DEFINITION.
  PUBLIC SECTION.

    TYPES: ty_it_events TYPE STANDARD TABLE OF cntl_simple_event WITH DEFAULT KEY.

    CLASS-METHODS: on_button_click FOR EVENT button_click OF cl_column_tree_model
      IMPORTING
          node_key
          item_name
          sender.

    CLASS-METHODS: on_link_click FOR EVENT link_click OF cl_column_tree_model
      IMPORTING
          node_key
          item_name
          sender.

    CLASS-METHODS: on_checkbox_change FOR EVENT checkbox_change OF cl_column_tree_model
      IMPORTING
          node_key
          item_name
          checked
          sender.

    CLASS-METHODS: on_header_click FOR EVENT header_click OF cl_column_tree_model
      IMPORTING
          header_name
          sender.

ENDCLASS.

CLASS lcl_events IMPLEMENTATION.

  METHOD on_button_click.
    MESSAGE node_key && '_' && item_name TYPE 'S'.
  ENDMETHOD.

  METHOD on_link_click.
    MESSAGE node_key && '_' && item_name TYPE 'S'.
  ENDMETHOD.

  METHOD on_checkbox_change.
    MESSAGE node_key && '_' && item_name && '_' && checked TYPE 'S'.
  ENDMETHOD.

  METHOD on_header_click.
    MESSAGE header_name TYPE 'S'.
  ENDMETHOD.

ENDCLASS.

START-OF-SELECTION.
* Tree-Control erzeugen
* item_selection = abap_true wegen der CheckBoxen
  DATA(o_tree) = NEW cl_column_tree_model( node_selection_mode   = cl_column_tree_model=>node_sel_mode_single
                                           hierarchy_column_name = 'FOLDER'
                                           hierarchy_header      = VALUE #( t_image = icon_folder
                                                                            heading = 'Beispiel'
                                                                            tooltip = 'Tooltip'
                                                                            width   = 30
                                                                          )
                                           item_selection        = abap_true
                                         ).
* Spalten hinzufügen
  o_tree->add_column( EXPORTING
                        name                = 'COL1'
                        width               = 30
                        header_text         = 'Column1' ).

  o_tree->add_column( EXPORTING
                        name                = 'COL2'
                        width               = 30
                        header_text         = 'Column2' ).

* in default_screen einbetten
  o_tree->create_tree_control( parent = cl_gui_container=>default_screen ).

* Beispielhaft Nodes und Subnodes erzeugen
  o_tree->add_node( EXPORTING
                      isfolder          = abap_true
                      node_key          = 'NODE1'
                      relative_node_key = ''
                      relationship      = cl_tree_model=>relat_last_child
                      expanded_image    = CONV tv_image( icon_folder )
                      image             = CONV tv_image( icon_folder )
                      item_table        = VALUE #( ( class     = cl_column_tree_model=>item_class_checkbox
                                                     item_name = 'FOLDER'
                                                     text      = 'Obj1'
                                                     editable  = abap_true
                                                   )
                                                 )
                  ).

  o_tree->add_node( EXPORTING
                      isfolder          = abap_true
                      node_key          = 'NODE1_1'
                      relative_node_key = 'NODE1'
                      relationship      = cl_tree_model=>relat_last_child
                      expanded_image    = CONV tv_image( icon_oo_object )
                      image             = CONV tv_image( icon_oo_object )
                      item_table        = VALUE #( ( class     = cl_column_tree_model=>item_class_link
                                                     item_name = 'FOLDER'
                                                     text      = 'Obj4'
                                                   )
                                                   ( class     = cl_column_tree_model=>item_class_text
                                                     item_name = 'COL1'
                                                     text      = 'Wert1'
                                                     style     = cl_column_tree_model=>style_intensified
                                                     font      = cl_column_tree_model=>item_font_prop
                                                   )
                                                   ( class     = cl_column_tree_model=>item_class_text
                                                     item_name = 'COL2'
                                                     text      = 'Wert2'
                                                   )
                                                 )
                  ).

  o_tree->add_node( EXPORTING
                      isfolder          = abap_true
                      node_key          = 'NODE2'
                      relative_node_key = ''
                      relationship      = cl_tree_model=>relat_last_child
                      expanded_image    = CONV tv_image( icon_folder )
                      image             = CONV tv_image( icon_folder )
                      item_table        = VALUE #( ( class     = cl_column_tree_model=>item_class_checkbox
                                                     item_name = 'FOLDER'
                                                     text      = 'Obj2'
                                                     editable  = abap_true
                                                   )
                                                 )
                  ).

  o_tree->add_node( EXPORTING
                      isfolder          = abap_true
                      node_key          = 'NODE2_1'
                      relative_node_key = 'NODE2'
                      relationship      = cl_tree_model=>relat_last_child
                      expanded_image    = CONV tv_image( icon_oo_object )
                      image             = CONV tv_image( icon_oo_object )
                      item_table        = VALUE #( ( class     = cl_column_tree_model=>item_class_button
                                                     item_name = 'FOLDER'
                                                     text      = 'Obj3'
                                                   )
                                                   ( class     = cl_column_tree_model=>item_class_text
                                                     item_name = 'COL1'
                                                     text      = 'Wert1'
                                                     style     = cl_column_tree_model=>style_inactive
                                                     font      = cl_column_tree_model=>item_font_prop
                                                   )
                                                   ( class     = cl_column_tree_model=>item_class_text
                                                     item_name = 'COL2'
                                                     text      = 'Wert2'
                                                   )
                                                 )
                  ).

* Nodes expandieren
  o_tree->expand_root_nodes( expand_subtree = abap_true
                             level_count = 10 ).

* Events registrieren
* ITEM_DOUBLE_CLICK	           Doppelklick auf Item
* BUTTON_CLICK                 Drucktaste wurde gedrückt
* LINK_CLICK                   Link geklickt
* CHECKBOX_CHANGE              Zustandsänderung einer Checkbox
* ITEM_KEYPRESS                Taste wurde gedrückt, Item war selektiert
* HEADER_CLICK                 Header geklickt
* ITEM_CONTEXT_MENU_REQUEST    Anforderung eines Kontext-Menüs für ein Item
* ITEM_CONTEXT_MENU_SELECT     Kontext-Menü Eintrag wurde ausgewählt
* HEADER_CONTEXT_MENU_REQUEST  Anforderung eines Kontext-Menüs für einen Header
* HEADER_CONTEXT_MENU_SELECT   Kontext-Menü Eintrag wurde ausgewählt
* DRAG                         Ereignis zum Füllen des Drag Drop Daten - Objekts
* DRAG_MULTIPLE                Ereignis zum Füllen des Drag Drop Daten - Objekts
* DROP_COMPLETE                Ereignis nach erfolgreichem Drop
* DROP_COMPLETE_MULTIPLE       Ereignis nach erfolgreichem Drop
  SET HANDLER lcl_events=>on_button_click FOR o_tree.
  SET HANDLER lcl_events=>on_checkbox_change FOR o_tree.
  SET HANDLER lcl_events=>on_header_click FOR o_tree.
  SET HANDLER lcl_events=>on_link_click FOR o_tree.

* Eventtypten müssen gesondert registriert werden
  DATA(it_events) = VALUE lcl_events=>ty_it_events(
                                                    ( eventid = cl_column_tree_model=>eventid_button_click
                                                      appl_event = abap_true )
                                                    ( eventid = cl_column_tree_model=>eventid_checkbox_change
                                                      appl_event = abap_true )
                                                    ( eventid = cl_column_tree_model=>eventid_header_click
                                                      appl_event = abap_true )
                                                    ( eventid = cl_column_tree_model=>eventid_link_click
                                                      appl_event = abap_true )
                                                  ).

  o_tree->set_registered_events( events = it_events ).

* Erzeugung von cl_gui_container=>default_screen erzwingen
  WRITE: space.

[ABAP] Beispiel für die Verwendung von CL_LIST_TREE_MODEL

* Demoprogramm: SAP_LIST_TREE_MODEL_DEMO
* http://saphelp.ucc.ovgu.de/NW750/EN/4d/88f020981740abe10000000a15822b/frameset.htm
* Eventhandler-Klasse
CLASS lcl_events DEFINITION.
  PUBLIC SECTION.

    TYPES: ty_it_events TYPE STANDARD TABLE OF cntl_simple_event WITH DEFAULT KEY.

    CLASS-METHODS: on_button_click FOR EVENT button_click OF cl_list_tree_model
      IMPORTING
          node_key
          item_name
          sender.

    CLASS-METHODS: on_link_click FOR EVENT link_click OF cl_list_tree_model
      IMPORTING
          node_key
          item_name
          sender.

    CLASS-METHODS: on_checkbox_change FOR EVENT checkbox_change OF cl_list_tree_model
      IMPORTING
          node_key
          item_name
          checked
          sender.

    CLASS-METHODS: on_header_click FOR EVENT header_click OF cl_list_tree_model
      IMPORTING
          header_name
          sender.

ENDCLASS.

CLASS lcl_events IMPLEMENTATION.

  METHOD on_button_click.
    MESSAGE node_key && '_' && item_name TYPE 'S'.
  ENDMETHOD.

  METHOD on_link_click.
    MESSAGE node_key && '_' && item_name TYPE 'S'.
  ENDMETHOD.

  METHOD on_checkbox_change.
    MESSAGE node_key && '_' && item_name && '_' && checked TYPE 'S'.
  ENDMETHOD.

  METHOD on_header_click.
    MESSAGE header_name TYPE 'S'.
  ENDMETHOD.

ENDCLASS.

START-OF-SELECTION.
* Tree-Control erzeugen
* item_selection = abap_true wegen der CheckBoxen
  DATA(o_tree) = NEW cl_list_tree_model( node_selection_mode = cl_list_tree_model=>node_sel_mode_single
                                         item_selection      = abap_true
                                         with_headers        = abap_true
                                         hierarchy_header      = VALUE #( t_image = icon_folder
                                                                          heading = 'Beispiel'
                                                                          tooltip = 'Tooltip'
                                                                          width   = 80
                                                                        )
                                       ).

* in default_screen einbetten
  o_tree->create_tree_control( parent = cl_gui_container=>default_screen ).

* Beispielhaft Nodes und Subnodes erzeugen
  o_tree->add_node( EXPORTING
                      isfolder          = abap_true
                      node_key          = 'NODE1'
                      relative_node_key = ''
                      relationship      = cl_tree_model=>relat_last_child
                      expanded_image    = CONV tv_image( icon_folder )
                      image             = CONV tv_image( icon_folder )
                      item_table        = VALUE #( ( class     = cl_list_tree_model=>item_class_checkbox
                                                     item_name = '1'
                                                     text      = 'Obj1'
                                                     editable  = abap_true
                                                     length    = 10
                                                   )
                                                 )
                  ).

  o_tree->add_node( EXPORTING
                      isfolder          = abap_false
                      node_key          = 'NODE1_1'
                      relative_node_key = 'NODE1'
                      relationship      = cl_tree_model=>relat_last_child
                      expanded_image    = CONV tv_image( icon_oo_object )
                      image             = CONV tv_image( icon_oo_object )
                      item_table        = VALUE #( ( class     = cl_list_tree_model=>item_class_link
                                                     item_name = '1'
                                                     text      = 'Obj4'
                                                     length    = 10
                                                   )
                                                   ( class     =  cl_list_tree_model=>item_class_text
                                                     item_name = '2'
                                                     text      = 'Wert1'
                                                     length    = 10
                                                   )
                                                   ( class     =  cl_list_tree_model=>item_class_text
                                                     item_name = '3'
                                                     text      = 'Wert2'
                                                     length    = 10
                                                     alignment = cl_list_tree_model=>align_auto
                                                     font      = cl_list_tree_model=>item_font_prop
                                                   )
                                                 )
                  ).

  o_tree->add_node( EXPORTING
                      isfolder          = abap_true
                      node_key          = 'NODE2'
                      relative_node_key = ''
                      relationship      = cl_tree_model=>relat_last_child
                      expanded_image    = CONV tv_image( icon_folder )
                      image             = CONV tv_image( icon_folder )
                      item_table        = VALUE #( ( class     = cl_list_tree_model=>item_class_checkbox
                                                     item_name = '1'
                                                     text      = 'Obj2'
                                                     editable  = abap_true
                                                     length    = 10
                                                   )
                                                 )
                  ).

  o_tree->add_node( EXPORTING
                      isfolder          = abap_false
                      node_key          = 'NODE2_1'
                      relative_node_key = 'NODE2'
                      relationship      = cl_tree_model=>relat_last_child
                      expanded_image    = CONV tv_image( icon_oo_object )
                      image             = CONV tv_image( icon_oo_object )
                      item_table        = VALUE #( ( class     = cl_list_tree_model=>item_class_button
                                                     item_name = '1'
                                                     text      = 'Obj3'
                                                     length    = 10
                                                   )
                                                   ( class     =  cl_list_tree_model=>item_class_text
                                                     item_name = '2'
                                                     text      = 'Wert1'
                                                     length    = 10
                                                   )
                                                   ( class     =  cl_list_tree_model=>item_class_text
                                                     item_name = '3'
                                                     text      = 'Wert2'
                                                     length    = 10
                                                     alignment = cl_list_tree_model=>align_auto
                                                     font      = cl_list_tree_model=>item_font_prop
                                                   )
                                                 )
                  ).

* Nodes expandieren
  o_tree->expand_root_nodes( expand_subtree = abap_true
                             level_count = 10 ).

* Events registrieren
* ITEM_DOUBLE_CLICK	           Doppelklick auf Item
* BUTTON_CLICK                 Drucktaste wurde gedrückt
* LINK_CLICK                   Link geklickt
* CHECKBOX_CHANGE              Zustandsänderung einer Checkbox
* ITEM_KEYPRESS                Taste wurde gedrückt, Item war selektiert
* HEADER_CLICK                 Header geklickt
* ITEM_CONTEXT_MENU_REQUEST    Anforderung eines Kontext-Menüs für ein Item
* ITEM_CONTEXT_MENU_SELECT     Kontext-Menü Eintrag wurde ausgewählt
* HEADER_CONTEXT_MENU_REQUEST  Anforderung eines Kontext-Menüs für einen Header
* HEADER_CONTEXT_MENU_SELECT   Kontext-Menü Eintrag wurde ausgewählt
* DRAG                         Ereignis zum Füllen des Drag Drop Daten - Objekts
* DRAG_MULTIPLE                Ereignis zum Füllen des Drag Drop Daten - Objekts
* DROP_COMPLETE                Ereignis nach erfolgreichem Drop
* DROP_COMPLETE_MULTIPLE       Ereignis nach erfolgreichem Drop
  SET HANDLER lcl_events=>on_button_click FOR o_tree.
  SET HANDLER lcl_events=>on_checkbox_change FOR o_tree.
  SET HANDLER lcl_events=>on_header_click FOR o_tree.
  SET HANDLER lcl_events=>on_link_click FOR o_tree.

* Eventtypten müssen gesondert registriert werden
  DATA(it_events) = VALUE lcl_events=>ty_it_events(
                                                    ( eventid = cl_list_tree_model=>eventid_button_click
                                                      appl_event = abap_true )
                                                    ( eventid = cl_list_tree_model=>eventid_checkbox_change
                                                      appl_event = abap_true )
                                                    ( eventid = cl_list_tree_model=>eventid_header_click
                                                      appl_event = abap_true )
                                                    ( eventid = cl_list_tree_model=>eventid_link_click
                                                      appl_event = abap_true )
                                                  ).

  o_tree->set_registered_events( events = it_events ).

* Erzeugung von cl_gui_container=>default_screen erzwingen
  WRITE: space.

[ABAP] Neuen Modus öffnen, Transaktion ausführen, Modus schließen

TRY.
* Modus öffnen
    DATA: o_mode TYPE REF TO if_imc_child_mode.

    cl_imc_mode=>create_mode( EXPORTING modetype = cl_imc_mode=>modetype_main_mode
                              IMPORTING mode     = o_mode ).

* Transaktion starten
    o_mode->call( tcode = 'SE11'
*              data  =
                ).

    DATA: ret TYPE string.

* Modus wieder schließen?
    CALL FUNCTION 'POPUP_TO_CONFIRM'
      EXPORTING
        titlebar              = 'Frage'
        text_question         = 'Modus wieder schließen?'
        display_cancel_button = abap_false
      IMPORTING
        answer                = ret.

    CASE ret.
      WHEN '1'.
* Ja -> Modus schließen
        o_mode->close( ).
    ENDCASE.
  CATCH cx_root INTO DATA(e_txt).
ENDTRY.

[ABAP] Vertikaler Tabstrip-Container für Controls (CL_GUI_CONTAINER_BAR_XT, CL_GUI_CONTAINER_BAR_2, CL_GUI_CONTAINER_BAR)

Variante 1 (CL_GUI_CONTAINER_BAR_XT)

CLASS lcl_events DEFINITION.
  PUBLIC SECTION.
    CLASS-METHODS:
      on_clicked FOR EVENT clicked OF cl_gui_container_bar_xt
        IMPORTING
            id
            container
            sender.
    CLASS-METHODS:
      on_empty FOR EVENT empty OF cl_gui_container_bar_xt
        IMPORTING
            sender.
    CLASS-METHODS:
      on_closed FOR EVENT closed OF cl_gui_container_bar_xt
        IMPORTING
            id
            sender.
ENDCLASS.

CLASS lcl_events IMPLEMENTATION.
* Eintrag angeklickt
  METHOD on_clicked.
    MESSAGE |Property: { id } { container->get_container_type( ) }| TYPE 'S'.
  ENDMETHOD.
* wenn keine Einträge mehr vorhanden (z.B. alle durch Klick auf die Schließen-Kreuze geschlossen)
  METHOD on_empty.
    BREAK-POINT.
  ENDMETHOD.
* wenn Schließen-Kreuz eines Eintrages geklickt
  METHOD on_closed.
    BREAK-POINT.
  ENDMETHOD.
ENDCLASS.

INITIALIZATION.
  TRY.
* Vertikalen Splitter erzeugen
      DATA(o_splitter) = NEW cl_gui_splitter_container( parent                  = cl_gui_container=>default_screen
                                                        no_autodef_progid_dynnr = abap_true
                                                        rows                    = 1
                                                        columns                 = 2 ).

* 10% / 90% Teilung
      o_splitter->set_column_width( id = 1 width = 10 ).

      DATA(o_container_left) = o_splitter->get_container( row = 1 column = 1 ).
      DATA(o_container_right) = o_splitter->get_container( row = 1 column = 2 ).

* Zwei Einträge im cl_gui_container_bar_xt
      DATA(it_captions) = VALUE sbptcaptns( ( caption      = 'ABAP'
                                              icon         = icon_abap
                                              no_close     = abap_false
                                              name         = 'CAP1'
                                              invisible    = abap_false
                                              pre_inst     = abap_false
                                              reuse_cnt_of = '' )
                                            ( caption      = 'ABC'
                                              icon         = icon_abc
                                              no_close     = abap_false
                                              name         = 'CAP2'
                                              invisible    = abap_false
                                              pre_inst     = abap_false
                                              reuse_cnt_of = '' ) ).

* cl_gui_container_bar_xt im linken Splitter erzeugen
      DATA(o_toolbar_xt) = NEW cl_gui_container_bar_xt( active_id     = 1                                    " Nr. des aktiven Eintrages
                                                        parent        = o_container_left                     " Einbettung in linken Container
                                                        captions      = it_captions                          " Einträge
                                                        style         = cl_gui_container_bar_xt=>c_style_fix " Style: Fix = Feste Anordnung, Outlook = Anordnung klappt
                                                        close_buttons = abap_true ).                         " Schließen Kreuze anzeigen

* einen weiterer Eintrag im cl_gui_container_bar_xt hinzufügen
      DATA(lv_caption) = VALUE sbptcaptn( caption      = 'Activate'
                                          icon         = icon_activate
                                          no_close     = abap_false
                                          name         = 'CAP3'
                                          invisible    = abap_false
                                          pre_inst     = abap_false
                                          reuse_cnt_of = '' ).

* Eintrag einfügen und Id holen
      DATA(lv_id) = 0.
      o_toolbar_xt->add_cell( EXPORTING caption = lv_caption
                              CHANGING  id      = lv_id ).

* Testweise Container zum Eintrag ermitteln
      DATA(o_cont) = o_toolbar_xt->get_container( id = lv_id ).

* letzen Eintrag im cl_gui_container_bar_xt aktiv (ausgewählt) setzen
      o_toolbar_xt->set_active( id = lv_id ).

* Eventhandler registrieren
      SET HANDLER lcl_events=>on_clicked FOR o_toolbar_xt.
      SET HANDLER lcl_events=>on_empty FOR o_toolbar_xt.
      SET HANDLER lcl_events=>on_closed FOR o_toolbar_xt.

* im rechten Splitter Beispieldaten anzeigen
      DATA: it_sflight TYPE STANDARD TABLE OF sflight.

      SELECT * FROM sflight INTO TABLE @it_sflight.

      DATA: o_salv TYPE REF TO cl_salv_table.

      cl_salv_table=>factory( EXPORTING
                                r_container    = o_container_right
                              IMPORTING
                                r_salv_table   = o_salv
                              CHANGING
                                t_table        = it_sflight ).

      o_salv->get_functions( )->set_all( ).
      o_salv->display( ).

* leere Standard-Toolbar ausblenden
      cl_abap_list_layout=>suppress_toolbar( ).

* Ausgabe von cl_gui_container=>default_screen erzwingen
      WRITE: space.
    CATCH cx_root INTO DATA(e_txt).
  ENDTRY.

Variante 2 (CL_GUI_CONTAINER_BAR_2)

CLASS lcl_events DEFINITION.
  PUBLIC SECTION.
    CLASS-METHODS:
      on_clicked FOR EVENT clicked OF cl_gui_container_bar_2
        IMPORTING
            id
            container
            sender.
    CLASS-METHODS:
      on_empty FOR EVENT empty OF cl_gui_container_bar_2
        IMPORTING
            sender.
    CLASS-METHODS:
      on_closed FOR EVENT closed OF cl_gui_container_bar_2
        IMPORTING
            id
            sender.
ENDCLASS.

CLASS lcl_events IMPLEMENTATION.
* Eintrag angeklickt
  METHOD on_clicked.
    MESSAGE |Property: { id } { container->get_container_type( ) }| TYPE 'S'.
  ENDMETHOD.
* wenn keine Einträge mehr vorhanden (z.B. alle durch Klick auf die Schließen-Kreuze geschlossen)
  METHOD on_empty.
    BREAK-POINT.
  ENDMETHOD.
* wenn Schließen-Kreuz eines Eintrages geklickt
  METHOD on_closed.
    BREAK-POINT.
  ENDMETHOD.
ENDCLASS.

INITIALIZATION.
  TRY.
* Vertikalen Splitter erzeugen
      DATA(o_splitter) = NEW cl_gui_splitter_container( parent                  = cl_gui_container=>default_screen
                                                        no_autodef_progid_dynnr = abap_true
                                                        rows                    = 1
                                                        columns                 = 2 ).

* 10% / 90% Teilung
      o_splitter->set_column_width( id = 1 width = 10 ).

      DATA(o_container_left) = o_splitter->get_container( row = 1 column = 1 ).
      DATA(o_container_right) = o_splitter->get_container( row = 1 column = 2 ).

* Zwei Einträge im cl_gui_container_bar_2
      DATA(it_captions) = VALUE sbptcaptns( ( caption      = 'ABAP'
                                              icon         = icon_abap
                                              no_close     = abap_false
                                              name         = 'CAP1'
                                              invisible    = abap_false
                                              pre_inst     = abap_false
                                              reuse_cnt_of = '' )
                                            ( caption      = 'ABC'
                                              icon         = icon_abc
                                              no_close     = abap_false
                                              name         = 'CAP2'
                                              invisible    = abap_false
                                              pre_inst     = abap_false
                                              reuse_cnt_of = '' ) ).

* cl_gui_container_bar_2 im linken Splitter erzeugen
      DATA(o_toolbar) = NEW cl_gui_container_bar_2( active_id     = 1                                    " Nr. des aktiven Eintrages
                                                    parent        = o_container_left                     " Einbettung in linken Container
                                                    captions      = it_captions                          " Einträge
                                                    style         = cl_gui_container_bar_2=>c_style_tile " Style: Fix = Feste Anordnung, tile = Menü, Outlook = Anordnung klappt
                                                    close_buttons = abap_false ).                        " Schließen Kreuze anzeigen

* einen weiterer Eintrag im cl_gui_container_bar_2 hinzufügen
      DATA(lv_caption) = VALUE sbptcaptn( caption      = 'Activate'
                                          icon         = icon_activate
                                          no_close     = abap_false
                                          name         = 'CAP3'
                                          invisible    = abap_false
                                          pre_inst     = abap_false
                                          reuse_cnt_of = '' ).

* Eintrag einfügen und Id holen
      DATA(lv_id) = 0.
      o_toolbar->add_cell( EXPORTING caption = lv_caption
                           CHANGING  id      = lv_id ).

* Testweise Container zum Eintrag ermitteln
      DATA(o_cont) = o_toolbar->get_container( id = lv_id ).

* letzen Eintrag im cl_gui_container_bar_2 aktiv (ausgewählt) setzen
      o_toolbar->set_active( id = lv_id ).

* Eventhandler registrieren
      SET HANDLER lcl_events=>on_clicked FOR o_toolbar.
      SET HANDLER lcl_events=>on_empty FOR o_toolbar.
      SET HANDLER lcl_events=>on_closed FOR o_toolbar.

* im rechten Splitter Beispieldaten anzeigen
      DATA: it_sflight TYPE STANDARD TABLE OF sflight.

      SELECT * FROM sflight INTO TABLE @it_sflight.

      DATA: o_salv TYPE REF TO cl_salv_table.

      cl_salv_table=>factory( EXPORTING
                                r_container    = o_container_right
                              IMPORTING
                                r_salv_table   = o_salv
                              CHANGING
                                t_table        = it_sflight ).

      o_salv->get_functions( )->set_all( ).
      o_salv->display( ).

* leere Standard-Toolbar ausblenden
      cl_abap_list_layout=>suppress_toolbar( ).

* Ausgabe von cl_gui_container=>default_screen erzwingen
      WRITE: space.
    CATCH cx_root INTO DATA(e_txt).
  ENDTRY.

Variante 3 (CL_GUI_CONTAINER_BAR)

CLASS lcl_events DEFINITION.
  PUBLIC SECTION.
    CLASS-METHODS:
      on_clicked FOR EVENT clicked OF cl_gui_container_bar
        IMPORTING
            id
            container
            sender.
ENDCLASS.

CLASS lcl_events IMPLEMENTATION.
* Eintrag angeklickt
  METHOD on_clicked.
    MESSAGE |Property: { id } { container->get_container_type( ) }| TYPE 'S'.
  ENDMETHOD.
ENDCLASS.

INITIALIZATION.
  TRY.
* Vertikalen Splitter erzeugen
      DATA(o_splitter) = NEW cl_gui_splitter_container( parent                  = cl_gui_container=>default_screen
                                                        no_autodef_progid_dynnr = abap_true
                                                        rows                    = 1
                                                        columns                 = 2 ).

* 10% / 90% Teilung
      o_splitter->set_column_width( id = 1 width = 10 ).

      DATA(o_container_left) = o_splitter->get_container( row = 1 column = 1 ).
      DATA(o_container_right) = o_splitter->get_container( row = 1 column = 2 ).

* Drei Einträge im cl_gui_container_bar
      DATA(it_captions) = VALUE sbptcaptns( ( caption      = 'ABAP'
                                              icon         = icon_abap
                                              no_close     = abap_false
                                              name         = 'CAP1'
                                              invisible    = abap_false
                                              pre_inst     = abap_false
                                              reuse_cnt_of = '' )
                                            ( caption      = 'ABC'
                                              icon         = icon_abc
                                              no_close     = abap_false
                                              name         = 'CAP2'
                                              invisible    = abap_false
                                              pre_inst     = abap_false
                                              reuse_cnt_of = '' )
                                            ( caption      = 'Activate'
                                              icon         = icon_activate
                                              no_close     = abap_false
                                              name         = 'CAP3'
                                              invisible    = abap_false
                                              pre_inst     = abap_false
                                              reuse_cnt_of = '' ) ).

* cl_gui_container_bar im linken Splitter erzeugen
      DATA(o_toolbar) = NEW cl_gui_container_bar( active_id     = 1                " Nr. des aktiven Eintrages
                                                  parent        = o_container_left " Einbettung in linken Container
                                                  captions      = it_captions ).   " Einträge

* Eventhandler registrieren
      SET HANDLER lcl_events=>on_clicked FOR o_toolbar.

* im rechten Splitter Beispieldaten anzeigen
      DATA: it_sflight TYPE STANDARD TABLE OF sflight.

      SELECT * FROM sflight INTO TABLE @it_sflight.

      DATA: o_salv TYPE REF TO cl_salv_table.

      cl_salv_table=>factory( EXPORTING
                                r_container    = o_container_right
                              IMPORTING
                                r_salv_table   = o_salv
                              CHANGING
                                t_table        = it_sflight ).

      o_salv->get_functions( )->set_all( ).
      o_salv->display( ).

* leere Standard-Toolbar ausblenden
      cl_abap_list_layout=>suppress_toolbar( ).

* Ausgabe von cl_gui_container=>default_screen erzwingen
      WRITE: space.
    CATCH cx_root INTO DATA(e_txt).
  ENDTRY.

[ABAP] Verwendung des GUI-Controls cl_gui_calendar

* SAPCALENDAR_DEMO1
* SAPCALENDAR_DRAG_DROP
* RSDEMO_CALENDAR_CONTROL
DATA: o_cnt TYPE REF TO cl_gui_dialogbox_container.
DATA: o_cal TYPE REF TO cl_gui_calendar.

* Dummyparameter für Selektion im Kalender
PARAMETERS: p_week TYPE string.
PARAMETERS: p_date TYPE string.

CLASS lcl_events DEFINITION.
  PUBLIC SECTION.
    CLASS-METHODS on_close FOR EVENT close OF cl_gui_dialogbox_container
      IMPORTING
          sender.
    CLASS-METHODS on_date_selected FOR EVENT date_selected OF cl_gui_calendar
      IMPORTING
          date_begin
          date_end
          sender.
ENDCLASS.

CLASS lcl_events IMPLEMENTATION.
* Event, wenn auf das Schließen-Kreuz geklickt wird
  METHOD on_close.
    sender->free( ).
  ENDMETHOD.

* Event für Datumsselektion im Kalender
  METHOD on_date_selected.
    DATA: lv_date_begin TYPE cnca_utc_date.

    TRY.
        sender->get_selection( IMPORTING date_begin = lv_date_begin ).

        p_week = cl_bs_period_toolset_basics=>get_calendar_week( CONV #( lv_date_begin ) ).
        p_date = lv_date_begin.
      CATCH cx_root INTO DATA(e_txt).
    ENDTRY.

  ENDMETHOD.

ENDCLASS.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_week.
* Popupfenster
  o_cnt = NEW #( no_autodef_progid_dynnr = abap_true
                 caption = 'Kalender'
                 top = 100
                 left = 200
                 width = 640
                 height = 120 ).

* on_close Handler für Popup setzen
  SET HANDLER lcl_events=>on_close FOR o_cnt.

* neues Kalenderobjekt erzeugen (überschreibt vorherige Referenz!)
  o_cal = NEW #( parent          = o_cnt
                 selection_style = cnca_sel_week
                 view_style      = cnca_style_h_navigator ).

  DATA: it_events TYPE cntl_simple_events.

  it_events = VALUE #( ( eventid = cl_gui_calendar=>m_id_date_selected
                         appl_event = abap_true ) ).

  o_cal->set_registered_events( events = it_events ).

  SET HANDLER lcl_events=>on_date_selected FOR o_cal.

START-OF-SELECTION.
  WRITE / p_week.
  WRITE / p_date.