[ABAP] Mehrere interne Tabellen in eigenem Fullscreen-Fenster (cl_gui_dialogbox_container) anzeigen

CLASS lcl_show_window DEFINITION FINAL.

  PUBLIC SECTION.

    CLASS-METHODS show
      IMPORTING
        !i_title TYPE string
      CHANGING
        !c_itab  TYPE STANDARD TABLE .

    CLASS-METHODS show2
      IMPORTING
        !i_title1 TYPE string
        !i_title2 TYPE string
      CHANGING
        !c_itab1  TYPE STANDARD TABLE
        !c_itab2  TYPE STANDARD TABLE .

  PROTECTED SECTION.

  PRIVATE SECTION.

    CLASS-METHODS on_close
      FOR EVENT close OF cl_gui_dialogbox_container
      IMPORTING
        !sender .
ENDCLASS.

CLASS lcl_show_window IMPLEMENTATION.

  METHOD on_close.
    IF sender IS NOT INITIAL.
      sender->free( ).
    ENDIF.
  ENDMETHOD.

  METHOD show.

    TRY.
* Window-Style hier ohne cl_gui_control=>ws_thickframe vordefinieren, da sonst das Fenster nicht richtig maximized werden kann
        DATA(i_style) = cl_gui_control=>ws_minimizebox + cl_gui_control=>ws_maximizebox + cl_gui_control=>ws_sysmenu.

* Bildschirmauflösung ermitteln
        DATA(lv_metric_factors) = cl_gui_props_consumer=>create_consumer( )->get_metric_factors( ).

* https://download.consolut.com/direct/SAP_PrintDoku/de/BCCIDOCK/BCCIDOCK.PDF
* Top, Left, Width, Height in Pixel
        DATA(o_cnt) = NEW cl_gui_dialogbox_container( no_autodef_progid_dynnr = abap_true
                                                      caption                 = |{ i_title }|
                                                      top                     = 1
                                                      left                    = 1
                                                      width                   = lv_metric_factors-screen-x
                                                      height                  = lv_metric_factors-screen-y
                                                      style                   = i_style
                                                      metric                  = cl_gui_dialogbox_container=>metric_pixel ).

* Dialogbox-Container fullscreen (maximized) setzen
*        o_cnt->set_alignment( cl_gui_control=>align_at_left + cl_gui_control=>align_at_right + cl_gui_control=>align_at_top + cl_gui_control=>align_at_bottom ).

* OnClose-Handler für cl_gui_dialogbox_container
        SET HANDLER on_close FOR o_cnt.

* SALV-Grid
        DATA: o_salv TYPE REF TO cl_salv_table.

        cl_salv_table=>factory( EXPORTING r_container  = o_cnt
                                IMPORTING r_salv_table = o_salv
                                CHANGING  t_table      = c_itab ).

        o_salv->get_functions( )->set_all( abap_true ).
        o_salv->get_columns( )->set_optimize( abap_true ).
        o_salv->get_display_settings( )->set_list_header( |{ i_title }| ).
        o_salv->get_display_settings( )->set_striped_pattern( abap_true ).
        o_salv->get_selections( )->set_selection_mode( if_salv_c_selection_mode=>row_column ).

        o_salv->display( ).

      CATCH cx_root.
    ENDTRY.
  ENDMETHOD.

  METHOD show2.

    TRY.
* Window-Style hier ohne cl_gui_control=>ws_thickframe vordefinieren, da sonst das Fenster nicht richtig maximized werden kann
        DATA(i_style) = cl_gui_control=>ws_minimizebox + cl_gui_control=>ws_maximizebox + cl_gui_control=>ws_sysmenu.

* Bildschirmauflösung ermitteln
        DATA(lv_metric_factors) = cl_gui_props_consumer=>create_consumer( )->get_metric_factors( ).

* https://download.consolut.com/direct/SAP_PrintDoku/de/BCCIDOCK/BCCIDOCK.PDF
* Top, Left, Width, Height in Pixel
        DATA(o_cnt) = NEW cl_gui_dialogbox_container( no_autodef_progid_dynnr = abap_true
                                                      caption                 = |{ i_title1 }, { i_title2 }|
                                                      top                     = 1
                                                      left                    = 1
                                                      width                   = lv_metric_factors-screen-x
                                                      height                  = lv_metric_factors-screen-y
                                                      style                   = i_style
                                                      metric                  = cl_gui_dialogbox_container=>metric_pixel ).

* Dialogbox-Container fullscreen (maximized) setzen
*        o_cnt->set_alignment( cl_gui_control=>align_at_left + cl_gui_control=>align_at_right + cl_gui_control=>align_at_top + cl_gui_control=>align_at_bottom ).

* OnClose-Handler für cl_gui_dialogbox_container
        SET HANDLER on_close FOR o_cnt.

* Referenzen auf GUI-Objekte
* Splitter
        DATA: o_splitter TYPE REF TO cl_gui_splitter_container.

* horizontaler Splitter in cl_gui_dialogbox_container einbetten
        o_splitter = NEW #( parent                  = o_cnt
                            no_autodef_progid_dynnr = abap_true
                            rows                    = 2
                            columns                 = 1 ).

* Splittercontainer auf 50%
        o_splitter->set_row_height( id = 1 height = 50 ).

* Splittercontainer oben/unten holen
        DATA(o_cnt_s1) = o_splitter->get_container( row = 1 column = 1 ).
        DATA(o_cnt_s2) = o_splitter->get_container( row = 2 column = 1 ).

* SALV-Grid 1 in Splittercontainer oben
        DATA: o_salv1 TYPE REF TO cl_salv_table.

        cl_salv_table=>factory( EXPORTING r_container  = o_cnt_s1
                                IMPORTING r_salv_table = o_salv1
                                CHANGING  t_table      = c_itab1 ).

        o_salv1->get_functions( )->set_all( abap_true ).
        o_salv1->get_columns( )->set_optimize( abap_true ).
        o_salv1->get_display_settings( )->set_list_header( |{ i_title1 }| ).
        o_salv1->get_display_settings( )->set_striped_pattern( abap_true ).
        o_salv1->get_selections( )->set_selection_mode( if_salv_c_selection_mode=>row_column ).

        o_salv1->display( ).

* SALV-Grid 2 in Splittercontainer unten
        DATA: o_salv2 TYPE REF TO cl_salv_table.

        cl_salv_table=>factory( EXPORTING r_container  = o_cnt_s2
                                IMPORTING r_salv_table = o_salv2
                                CHANGING  t_table      = c_itab2 ).

        o_salv2->get_functions( )->set_all( abap_true ).
        o_salv2->get_columns( )->set_optimize( abap_true ).
        o_salv2->get_display_settings( )->set_list_header( |{ i_title2 }| ).
        o_salv2->get_display_settings( )->set_striped_pattern( abap_true ).

        o_salv2->get_selections( )->set_selection_mode( if_salv_c_selection_mode=>row_column ).

        o_salv2->display( ).
      CATCH cx_root.
    ENDTRY.
  ENDMETHOD.
ENDCLASS.

START-OF-SELECTION.

* Beispieldaten
  SELECT
    FROM mara
    FIELDS *
    INTO TABLE @DATA(it_mara)
    UP TO 100 ROWS.

  IF sy-subrc = 0.
    SELECT
      FROM marc
      FIELDS *
      INTO TABLE @DATA(it_marc)
      UP TO 100 ROWS.

    IF sy-subrc = 0.
* interne Tabelle im Window anzeigen
      lcl_show_window=>show( EXPORTING i_title = |MARA|
                             CHANGING  c_itab  = it_mara ).

* zwei interne Tabellen in einem Window mit Splitter anzeigen
      lcl_show_window=>show2( EXPORTING i_title1 = |MARA|
                                        i_title2 = |MARC|
                              CHANGING  c_itab1  = it_mara
                                        c_itab2  = it_marc ).
    ENDIF.
  ENDIF.

* cl_gui_container=>default_screen erzwingen
  WRITE: space.

[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] Zwei SALV-Grids in einem Splittercontainer anzeigen

* Daten für SALV-Grid oben
SELECT *
  INTO TABLE @DATA(it_scarr)
  FROM scarr.

* Daten für SALV-Grid unten
SELECT *
  INTO TABLE @DATA(it_sflight)
  FROM sflight.

* Referenzen auf GUI-Objekte
* Splitter
DATA: o_splitter_main TYPE REF TO cl_gui_splitter_container.
* Splitter-Container oben
DATA: o_container_o   TYPE REF TO cl_gui_container.
* Splitter-Container unten
DATA: o_container_u   TYPE REF TO cl_gui_container.

* Splitter auf default_screen erzeugen
o_splitter_main = NEW #( parent                  = cl_gui_container=>default_screen
                         no_autodef_progid_dynnr = abap_true       " wichtig
                         rows                    = 2
                         columns                 = 1 ).

* Höhe oberer Splitter in %
o_splitter_main->set_row_height( id = 1 height = 40 ).

* REF auf oberen und unteren Splitcontainer holen
o_container_o = o_splitter_main->get_container( row = 1 column = 1 ).
o_container_u = o_splitter_main->get_container( row = 2 column = 1 ).

* SALV-Table oben mit Fluggesellschaften
DATA: o_salv_o TYPE REF TO cl_salv_table.

cl_salv_table=>factory( EXPORTING
                          r_container  = o_container_o
                        IMPORTING
                          r_salv_table = o_salv_o
                        CHANGING
                          t_table      = it_scarr ).

* Grundeinstellungen
o_salv_o->get_functions( )->set_all( abap_true ).
o_salv_o->get_columns( )->set_optimize( abap_true ).
o_salv_o->get_display_settings( )->set_list_header( 'Fluggesellschaften' ).
o_salv_o->get_display_settings( )->set_striped_pattern( abap_true ).
o_salv_o->get_selections( )->set_selection_mode( if_salv_c_selection_mode=>row_column ).

* Spaltenüberschriften: technischer Name und Beschreibungstexte
LOOP AT o_salv_o->get_columns( )->get( ) ASSIGNING FIELD-SYMBOL(<so>).
  DATA(o_col_o) = <so>-r_column.
  o_col_o->set_short_text( || ).
  o_col_o->set_medium_text( || ).
  o_col_o->set_long_text( |{ o_col_o->get_columnname( ) }| ).
ENDLOOP.

* SALV-Grid anzeigen
o_salv_o->display( ).

* SALV-Table unten mit Flügen
DATA: o_salv_u TYPE REF TO cl_salv_table.

cl_salv_table=>factory( EXPORTING
                          r_container  = o_container_u
                        IMPORTING
                          r_salv_table = o_salv_u
                        CHANGING
                          t_table      = it_sflight ).

* Grundeinstellungen
o_salv_u->get_functions( )->set_all( abap_true ).
o_salv_u->get_columns( )->set_optimize( abap_true ).
o_salv_u->get_display_settings( )->set_list_header( 'Flüge' ).
o_salv_u->get_display_settings( )->set_striped_pattern( abap_true ).
o_salv_u->get_selections( )->set_selection_mode( if_salv_c_selection_mode=>row_column ).

* Spaltenüberschriften: technischer Name und Beschreibungstexte
LOOP AT o_salv_u->get_columns( )->get( ) ASSIGNING FIELD-SYMBOL(<su>).
  DATA(o_col_u) = <su>-r_column.
  o_col_u->set_short_text( || ).
  o_col_u->set_medium_text( || ).
  o_col_u->set_long_text( |{ o_col_u->get_columnname( ) }| ).
ENDLOOP.

* SALV-Grid anzeigen
o_salv_u->display( ).

* leere Toolbar ausblenden
cl_abap_list_layout=>suppress_toolbar( ).

* Erzwingen von cl_gui_container=>default_screen
WRITE: space.

[ABAP] Docking Container (cl_gui_docking_container) maximiert darstellen

DATA: o_dock TYPE REF TO cl_gui_docking_container.
DATA: o_salv_ida TYPE REF TO if_salv_gui_table_ida.

PARAMETERS: p_name TYPE string. " Dummy-Parameter zum erzwingen des Selektionsbildes

AT SELECTION-SCREEN OUTPUT.

  IF NOT o_dock IS BOUND.
* maximierten Dockingcontainer auf dem Selektionsbild erzeugen
    o_dock = NEW #( repid     = sy-repid
                    dynnr     = sy-dynnr
                    side      = cl_gui_docking_container=>dock_at_bottom
                    extension = cl_gui_docking_container=>ws_maximizebox
*                    ratio     = 50
                  ).

* Testweise ein SALV TABLE IDA im Container einbetten
    o_salv_ida = cl_salv_gui_table_ida=>create( iv_table_name    = 'T100'
                                                io_gui_container = o_dock ).

  ENDIF.

[ABAP] GUI-Controls stapeln

* Quelle: https://www.tricktresor.de/blog/controls-stapeln/

DATA: it_mara TYPE STANDARD TABLE OF mara WITH DEFAULT KEY.
DATA: o_dock TYPE REF TO cl_gui_docking_container.
DATA: o_txt TYPE REF TO cl_gui_textedit.
DATA: o_alv TYPE REF TO cl_gui_alv_grid.

PARAMETERS: rb_txt RADIOBUTTON GROUP rbg DEFAULT 'X' USER-COMMAND rbc.
PARAMETERS: rb_alv RADIOBUTTON GROUP rbg.

INITIALIZATION.
  IF NOT o_dock IS BOUND.
* Containerobjekt erzeugen
    o_dock = NEW #( side  = cl_gui_docking_container=>dock_at_bottom
                    ratio = 90 ).

* Texteditor erzeugen
    o_txt = NEW #( parent = o_dock ).

* Daten für ALV holen
    SELECT *
      INTO TABLE @it_mara
      FROM mara
      UP TO 100 ROWS.

* ALV-Gitter erzeugen
    o_alv = NEW #( i_parent = o_dock ).
    o_alv->set_table_for_first_display( EXPORTING
                                          i_structure_name = 'MARA'
                                        CHANGING
                                          it_outtab = it_mara ).
  ENDIF.

AT SELECTION-SCREEN.
* wenn Radiobuttons geklickt
  IF sy-ucomm = 'RBC'.
* je nach Radiobutton die GUI-Controls ein-/ausblenden
    CASE abap_true.
      WHEN rb_txt.
        o_txt->set_visible( abap_true ).
        o_alv->set_visible( abap_false ).
      WHEN rb_alv.
        o_txt->set_visible( abap_false ).
        o_alv->set_visible( abap_true ).
    ENDCASE.
  ENDIF.

[ABAP] Globale Objekte eines Programms ermitteln und Infos anzeigen

Variante 1 (lokale Infoklasse)

* Quellen: https://blogs.sap.com/2018/08/27/sapgui-is-dying-but-still-secrets-to-reveal.../
*          https://github.com/tricktresor/container_hierarchy

CLASS lcl_global_symbols DEFINITION.
  PUBLIC SECTION.
    TYPES: BEGIN OF ty_obj_info,
             name          TYPE rfieldlist-name,
             type          TYPE rfieldlist-type,
             reftypeloc    TYPE rfieldlist-reftypeloc,
             global_name   TYPE string,
             relative_name TYPE string,
             object_name   TYPE string,
             object_id     TYPE i,
             reference     TYPE REF TO object,
             error         TYPE string,
           END OF ty_obj_info.

    TYPES: ty_it_obj_info TYPE STANDARD TABLE OF ty_obj_info WITH DEFAULT KEY.

    CONSTANTS: null TYPE REF TO object VALUE IS INITIAL.

    CLASS-METHODS:
      get_obj_info
        IMPORTING
                  iv_name               TYPE rfieldlist-name
                  iv_type               TYPE rfieldlist-type DEFAULT 'r'
                  iv_reftypeloc         TYPE rfieldlist-reftypeloc DEFAULT 'CLAS'
        RETURNING VALUE(rv_it_obj_info) TYPE ty_it_obj_info.
ENDCLASS.

CLASS lcl_global_symbols IMPLEMENTATION.
  METHOD get_obj_info.
    DATA: it_fieldlist TYPE STANDARD TABLE OF rfieldlist WITH DEFAULT KEY.
* Liste der globalen Daten eines Programms
    CALL FUNCTION 'GET_GLOBAL_SYMBOLS'
      EXPORTING
        program      = sy-repid
        name_pattern = '*'
      TABLES
        fieldlist    = it_fieldlist.

    DATA(lv_where) = ||.

    IF NOT iv_name IS INITIAL.
      lv_where = |name CP iv_name AND type = iv_type AND reftypeloc = iv_reftypeloc|.
    ENDIF.

    LOOP AT it_fieldlist ASSIGNING FIELD-SYMBOL(<f>) WHERE (lv_where).

      DATA(lv_global_name) = |({ sy-repid }){ <f>-name }|.
      DATA(lv_relative_name) = ||.
      DATA(lv_object_name) = ||.
      DATA(lv_error) = ||.
      DATA: lv_oid TYPE i.

* Wenn Referenztyp
      IF <f>-type = 'r'.
* Dirty Assign: Namen an Feldsymbol vom TYPE ANY binden
        ASSIGN (lv_global_name) TO FIELD-SYMBOL(<o>).

        IF NOT <o> IS INITIAL.
          IF <o> IS ASSIGNED.
            TRY.
* <o> ist eine Referenz
                IF <o> IS BOUND.
* Descriptor für Objektreferenz
                  DATA(o_desc) = cl_abap_typedescr=>describe_by_object_ref( <o> ).

                  lv_relative_name = o_desc->get_relative_name( ).

* ObjektID zur Referenz ermitteln
                  CALL 'OBJMGR_GET_INFO' ID 'OPNAME' FIELD 'GET_OBJID'
                                         ID 'OBJID'  FIELD lv_oid      " Rückgabe: ObjectID
                                         ID 'OBJ'    FIELD <o>.

                  lv_object_name = |\{O:{ lv_oid }*{ o_desc->absolute_name }|.
                ENDIF.
              CATCH cx_root INTO DATA(e_txt).
                lv_error = e_txt->get_text( ).
            ENDTRY.
          ENDIF.
        ENDIF.
      ENDIF.

      APPEND VALUE #(
                      name          = <f>-name
                      type          = <f>-type
                      reftypeloc    = <f>-reftypeloc
                      global_name   = lv_global_name
                      relative_name = lv_relative_name
                      object_name   = lv_object_name
                      object_id     = lv_oid
                      reference     = COND #( WHEN ( <o> IS ASSIGNED AND NOT <o> IS INITIAL ) THEN <o> ELSE null )
                      error         = lv_error
                    ) TO rv_it_obj_info.
    ENDLOOP.
  ENDMETHOD.
ENDCLASS.

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

PARAMETERS: p_matnr TYPE mara-matnr.

INITIALIZATION.

  IF NOT o_dock IS BOUND.
* GUI-Objekte für Test erzeugen
    o_dock = NEW #( side  = cl_gui_docking_container=>dock_at_bottom
                    ratio = 90 ).

    o_text = NEW #( parent = o_dock ).
  ENDIF.

START-OF-SELECTION.

* Infos zu 'o_dock' holen
  DATA(it_one) = lcl_global_symbols=>get_obj_info( iv_name = 'o_dock' ).

  LOOP AT it_one ASSIGNING FIELD-SYMBOL(<one>).

    DATA(lv_ref_one) = ||.

    IF <one>-reference IS BOUND.
      lv_ref_one = <one>-object_name.
    ENDIF.

    WRITE: / <one>-name, <one>-type, <one>-reftypeloc, <one>-global_name, <one>-relative_name, <one>-object_name, <one>-object_id, lv_ref_one, <one>-error.
  ENDLOOP.

  ULINE.

* Infos zu allen Objekten holen
  DATA(it_all) = lcl_global_symbols=>get_obj_info( iv_name = '' ).

  LOOP AT it_all ASSIGNING FIELD-SYMBOL(<o>).

    DATA(lv_ref) = ||.

    IF <o>-reference IS BOUND.
      lv_ref = <o>-object_name.
    ENDIF.

    WRITE: / <o>-name, <o>-type, <o>-reftypeloc, <o>-global_name, <o>-relative_name, <o>-object_name, <o>-object_id, lv_ref, <o>-error.
  ENDLOOP.

Variante 2 (Container)

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

DATA: it_fieldlist TYPE STANDARD TABLE OF rfieldlist WITH DEFAULT KEY.

PARAMETERS: p_matnr TYPE mara-matnr.

INITIALIZATION.

  IF NOT o_dock IS BOUND.
* GUI-Objekte für Test erzeugen
    o_dock = NEW #( side  = cl_gui_docking_container=>dock_at_bottom
                    ratio = 90 ).

    o_text = NEW #( parent = o_dock ).
  ENDIF.

AT SELECTION-SCREEN.
* Liste der globalen Daten eines Programms
  CALL FUNCTION 'GET_GLOBAL_SYMBOLS'
    EXPORTING
      program      = sy-repid
      name_pattern = '*'
    TABLES
      fieldlist    = it_fieldlist.

START-OF-SELECTION.
* globalen Daten nach Referenztypen durchloopen
  LOOP AT it_fieldlist ASSIGNING FIELD-SYMBOL(<f>) WHERE type = 'r' AND reftypeloc = 'CLAS' AND name(1) <> '%'.

    WRITE: / '         name:', <f>-name.

* Globalen Namen des Objekts ermitteln
    DATA(lv_global_name) = |({ sy-repid }){ <f>-name }|.
    WRITE: / '  global name:', lv_global_name.

* Dirty Assign: Namen an Feldsymbol vom TYPE ANY binden
    ASSIGN (lv_global_name) TO FIELD-SYMBOL(<o>).
    IF <o> IS ASSIGNED.
      TRY.
* <o> ist eine Referenz
          IF <o> IS BOUND.
* Descriptor für Objektreferenz
            DATA(o_desc) = cl_abap_typedescr=>describe_by_object_ref( <o> ).

            WRITE: / 'relative name:', o_desc->get_relative_name( ).

            DATA: lv_oid TYPE i.

* ObjektID zur Referenz ermitteln
            CALL 'OBJMGR_GET_INFO' ID 'OPNAME' FIELD 'GET_OBJID'
                                   ID 'OBJID'  FIELD lv_oid      " Rückgabe: ObjectID
                                   ID 'OBJ'    FIELD <o>.

            WRITE: / '  object name:', |\{O:{ lv_oid }*{ o_desc->absolute_name }|.

* Gegenprobe
            DATA: o_ref_weak TYPE REF TO object.

* Referenz zur ObjektID ermitteln
            CALL 'OBJMGR_GET_INFO' ID 'OPNAME' FIELD 'WEAK_REF_GET'
                                   ID 'OID'    FIELD lv_oid
                                   ID 'OBJ'    FIELD o_ref_weak. " Rückgabe: Objekt-Referenz

            IF o_ref_weak IS BOUND.
* Descriptor für Objektreferenz
              DATA(o_desc_weak) = cl_abap_typedescr=>describe_by_object_ref( o_ref_weak ).
              WRITE: / 'relative name weak:', o_desc_weak->get_relative_name( ).
              WRITE: / '  object name weak:', |\{O:{ lv_oid }*{ o_desc_weak->absolute_name }|.
            ENDIF.

* Falls cl_gui_container: Children anzeigen
            TRY.
                DATA(o_cont) = CAST cl_gui_container( <o> ).

                LOOP AT o_cont->children ASSIGNING FIELD-SYMBOL(<child>).
                  DATA(o_desc_child) = cl_abap_typedescr=>describe_by_object_ref( <child> ).
                  WRITE: / ' --> child relative name:', o_desc_child->get_relative_name( ).
                ENDLOOP.
              CATCH cx_root.
            ENDTRY.
          ELSE.
            WRITE: 'keine Referenz verfügbar.'.
          ENDIF.

        CATCH cx_root INTO DATA(e_txt).
          WRITE: / e_txt->get_text( ).
      ENDTRY.
    ELSE.
      WRITE: 'Feldsymbol nicht zugewiesen:', lv_global_name.
    ENDIF.

    ULINE.
  ENDLOOP.

[ABAP] GOS-Container (Generic Object Services) für Anzeige von beliebigen Objekten in der Titlebar nutzen

Variante 1 (cl_gui_toolbar)

* https://www.tricktresor.de/blog/hacking-sapgui/
DATA: o_cnt_gos TYPE REF TO cl_gui_gos_container.
DATA: o_toolbar TYPE REF TO cl_gui_toolbar.

* Eventhandler für Toolbar-Buttons
CLASS lcl_events DEFINITION.
  PUBLIC SECTION.

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

    CLASS-METHODS:
      on_function_selected FOR EVENT function_selected OF cl_gui_toolbar
        IMPORTING
            fcode.
ENDCLASS.

CLASS lcl_events IMPLEMENTATION.
  METHOD on_function_selected.
    MESSAGE fcode TYPE 'S'.
  ENDMETHOD.
ENDCLASS.

* Checkbox zum anzeigen / verstecken des GOS-Containers
PARAMETERS: p_chk1 AS CHECKBOX USER-COMMAND cmd1.

INITIALIZATION.
* GOS-Container mit Breite = 300
  o_cnt_gos = NEW #( width = 300 ).

* Toolbar horizontal mit Buttons
  o_toolbar = NEW #( parent       = o_cnt_gos
                     display_mode = cl_gui_toolbar=>m_mode_horizontal ).

  o_toolbar->add_button( fcode     = 'BTN1'
                         icon      = icon_open
                         butn_type = cntb_btype_button ).

  o_toolbar->add_button( fcode     = ''
                         icon      = ''
                         butn_type = cntb_btype_sep ).

  o_toolbar->add_button( fcode     = 'BTN2'
                         icon      = icon_system_save
                         butn_type = cntb_btype_button ).

  DATA(it_events) = VALUE lcl_events=>ty_it_events( ( eventid    = cl_gui_toolbar=>m_id_function_selected
                                                      appl_event = abap_true ) ).

  o_toolbar->set_registered_events( events = it_events ).

  SET HANDLER lcl_events=>on_function_selected FOR o_toolbar.

AT SELECTION-SCREEN.
  CASE sy-ucomm.
* Checkbox geklickt -> GOS-Container ein-/ausblenden
    WHEN 'CMD1'.
      o_cnt_gos->set_visible( COND abap_bool( WHEN p_chk1 = abap_true THEN abap_false ELSE abap_true ) ).
  ENDCASE.

START-OF-SELECTION.
  WRITE: / p_chk1.

Variante 2 (cl_gui_textedit)

DATA: o_cnt_gos TYPE REF TO cl_gui_gos_container.
DATA: o_edit TYPE REF TO cl_gui_textedit.

PARAMETERS: p_matnr type matnr.

INITIALIZATION.

* Fensterbreite des SAP-Fensters
  DATA(lv_x_metric) = cl_gui_cfw=>compute_metric_from_dynp( metric = cl_gui_control=>metric_pixel
                                                            x_or_y = 'X'
                                                            in = sy-scols ).

* GOS-Container mit akt. Fensterbreite
  o_cnt_gos = NEW #( width = lv_x_metric ).

* Editorzeile im Titel
  o_edit = NEW #( wordwrap_mode              = cl_gui_textedit=>wordwrap_at_windowborder
                  wordwrap_to_linebreak_mode = cl_gui_textedit=>true
                  parent                     = o_cnt_gos ).

* feste Zeichenbreite
  o_edit->set_font_fixed( mode = cl_gui_textedit=>true ).
* Anzeige von Toolbar und Statusbar des Texteditors unterdrücken
  o_edit->set_toolbar_mode( toolbar_mode = cl_gui_textedit=>false ).
  o_edit->set_statusbar_mode( statusbar_mode = cl_gui_textedit=>false ).
  o_edit->set_textstream( 'Testtext' ).

START-OF-SELECTION.
  IF o_edit IS BOUND.
* Text aus Editorzeile holen
    DATA(lv_text) = ||.

    o_edit->get_textstream( IMPORTING text = lv_text ).
    cl_gui_cfw=>flush( ).

    WRITE: / lv_text.
  ENDIF.

Variante 3 (cl_gui_html_viewer)

DATA: o_cnt_gos TYPE REF TO cl_gui_gos_container.
DATA: o_html TYPE REF TO cl_gui_html_viewer.

PARAMETERS: p_matnr TYPE matnr.

INITIALIZATION.

* Zeilen und Spalten in Pixel umrechnen
  DATA(lv_x_metric) = cl_gui_cfw=>compute_metric_from_dynp( metric = cl_gui_control=>metric_pixel
                                                            x_or_y = 'X'
                                                            in = sy-scols ).

* GOS-Container mit akt. Fensterbreite
  o_cnt_gos = NEW #( width = lv_x_metric ).

* HTML im Titlebar anzeigen
  o_html = NEW cl_gui_html_viewer( parent = o_cnt_gos ).

  DATA(it_html) = VALUE w3_htmltab( ( '<html><head><style>body { margin: 0; background-color: #00BBCC; color: #001122; font: 18px "Courier" }</style></head>' )
                                    ( '<body>Test</body></html>' ) ).
  DATA: lv_url TYPE swk_url.

  o_html->load_data( IMPORTING
                      assigned_url = lv_url
                    CHANGING
                      data_table   = it_html ).

  o_html->show_url( lv_url ).

START-OF-SELECTION.
  WRITE: / p_matnr.

[ABAP] Klasse zur Darstellung von Nachrichtentexten in einem SALV-Grid in einem Popup-Dialog

CLASS lcl_popup_msg_box DEFINITION.

  PUBLIC SECTION.
* Typ Textzeile
    TYPES: BEGIN OF ty_textline,
             idx  TYPE rspos,
             text TYPE bapi_msg,
           END OF ty_textline.

    TYPES: ty_it_messagetab TYPE STANDARD TABLE OF ty_textline WITH DEFAULT KEY.

* Typ Button-Event
    TYPES: ty_it_events TYPE STANDARD TABLE OF cntl_simple_event WITH DEFAULT KEY.

* Anzeige des Popups
    CLASS-METHODS show
      IMPORTING
                i_window_title   TYPE string
                i_window_top     TYPE i
                i_window_left    TYPE i
                i_window_width   TYPE i
                i_window_height  TYPE i
                i_show_functions TYPE boolean
                i_it_messages    TYPE ty_it_messagetab
      RETURNING VALUE(rv_ok)     TYPE boolean.

  PRIVATE SECTION.

* Button Funktionskonstanten
    CONSTANTS: co_btn_ok TYPE ui_func VALUE 'BTN_OK'.
    CONSTANTS: co_btn_cancel TYPE ui_func VALUE 'BTN_CANCEL'.

* Message-Tabelle
    CLASS-DATA: it_messages TYPE ty_it_messagetab.

* GUI-Objekte
    CLASS-DATA: o_cnt TYPE REF TO cl_gui_dialogbox_container.
    CLASS-DATA: o_salv TYPE REF TO cl_salv_table.
    CLASS-DATA: o_split TYPE REF TO cl_gui_splitter_container.
    CLASS-DATA: o_tool TYPE REF TO cl_gui_toolbar.
    CLASS-DATA: gv_retval TYPE boolean VALUE abap_false.

* on_close-Handler
    CLASS-METHODS:
      on_close FOR EVENT close OF cl_gui_dialogbox_container
        IMPORTING
            sender.
* on_function_selected Handler
    CLASS-METHODS:
      on_function_selected FOR EVENT function_selected OF cl_gui_toolbar
        IMPORTING
            fcode
            sender.

ENDCLASS.

CLASS lcl_popup_msg_box IMPLEMENTATION.

  METHOD show.

    it_messages = i_it_messages.

* Container für GUI-Elemente
    o_cnt = NEW #( parent = cl_gui_container=>default_screen
                   caption = |{ i_window_title }|
                   top = i_window_top
                   left = i_window_left
                   width = i_window_width
                   height = i_window_height
                   no_autodef_progid_dynnr = abap_true
                 ).

* on_close-Handler setzen
    SET HANDLER on_close FOR o_cnt.

* Splitter für Grid und Toolbar
    o_split = NEW #( parent = o_cnt
                     no_autodef_progid_dynnr = abap_true
                     rows = 2
                     columns = 1 ).

* Unteren Splitterbereich setzen
    o_split->set_row_sash( id    = 2
                           type  = cl_gui_splitter_container=>type_movable
                           value = cl_gui_splitter_container=>false ).

    o_split->set_row_sash( id    = 2
                           type  = cl_gui_splitter_container=>type_sashvisible
                           value = cl_gui_splitter_container=>false ).

    o_split->set_row_height( id = 2 height = 8 ).

* Oberen und unteren Splittercontainer holen
    DATA(o_container_top)    = o_split->get_container( row = 1 column = 1 ).
    DATA(o_container_bottom) = o_split->get_container( row = 2 column = 1 ).
* Toolbar für Buttons erzeugen
    DATA(o_tool) = NEW cl_gui_toolbar( parent       = o_container_bottom
                                       display_mode = cl_gui_toolbar=>m_mode_horizontal
                                       align_right  = 1 ).

* Toolbarevents
    DATA(it_events) = VALUE ty_it_events( ( eventid    = cl_gui_toolbar=>m_id_function_selected
                                            appl_event = abap_true ) ).

    o_tool->set_registered_events( events = it_events ).

* Buttons + Separator einfügen
    o_tool->add_button( fcode       = co_btn_ok
                        icon        = icon_okay
                        butn_type   = cntb_btype_button
                        text        = 'Ok'
                        quickinfo   = 'Ok'
                        is_checked  = abap_false
                        is_disabled = abap_false ).

    o_tool->add_button( fcode       = ''
                        icon        = ''
                        butn_type   = cntb_btype_sep
                        text        = ''
                        quickinfo   = ''
                        is_checked  = abap_false
                        is_disabled = abap_false ).

    o_tool->add_button( fcode       = co_btn_cancel
                        icon        = icon_cancel
                        butn_type   = cntb_btype_button
                        text        = 'Abbruch'
                        quickinfo   = 'Abbruch'
                        is_checked  = abap_false
                        is_disabled = abap_false ).

* on_function_selected-Handler
    SET HANDLER on_function_selected FOR o_tool.

* SALV-Grid im oberen Splitter einfügen
    cl_salv_table=>factory( EXPORTING
                              r_container  = o_container_top
                            IMPORTING
                              r_salv_table = o_salv
                            CHANGING
                              t_table      = it_messages ).

* Eigenschaften SALV-Grid
    o_salv->get_columns( )->set_optimize( abap_true ).
    o_salv->get_display_settings( )->set_striped_pattern( abap_true ).
    IF i_show_functions = abap_true.
      o_salv->get_functions( )->set_all( ).
    ENDIF.
    o_salv->get_selections( )->set_selection_mode( if_salv_c_selection_mode=>row_column ).
    o_salv->display( ).

* Dummy-Screen aufrufen und somit cl_gui_container=>default_screen erzeugen -> Trägerdynpro für cl_gui_dialogbox_container
    CALL SCREEN 100.

* nach Buttonclick noch die Ergebnisrückgabe
    rv_ok = gv_retval.
  ENDMETHOD.

  METHOD on_close.

* cl_gui_dialogbox_container bei Klick auf Schließen-Kreuz schließen
    IF sender IS NOT INITIAL.
      sender->free( ).
    ENDIF.

* Zum aufrufenden Dynpro zurück
    LEAVE TO SCREEN 0.

  ENDMETHOD.

* Button ermitteln -> Reaktion -> Setzen des Rückgabewertes beim Schließen des Popups
  METHOD on_function_selected.
    CASE fcode.
      WHEN co_btn_ok.
        gv_retval = abap_true.
      WHEN co_btn_cancel.
        gv_retval = abap_false.
    ENDCASE.

* Popup-Fenster schließen
    on_close( o_cnt ).
  ENDMETHOD.
ENDCLASS.

* Dummy-Screen für cl_gui_container=>default_screen deklarieren
SELECTION-SCREEN BEGIN OF SCREEN 100.
SELECTION-SCREEN END OF SCREEN 100.

START-OF-SELECTION.

* Nachrichtentabelle erzeugen
  DATA(it_msg) = VALUE lcl_popup_msg_box=>ty_it_messagetab( ( idx = 1 text = 'Nachricht 1' )
                                                            ( idx = 2 text = 'Nachricht 2' )
                                                          ).

* Popup mit Nachrichten anzeigen
  IF abap_true = lcl_popup_msg_box=>show( EXPORTING
                                            i_window_title   = 'Meldungen'
                                            i_window_top     = 100
                                            i_window_left    = 100
                                            i_window_width   = 240
                                            i_window_height  = 240
                                            i_show_functions = abap_false
                                            i_it_messages    = it_msg ).
    WRITE: / 'OK.'.
  ELSE.
    WRITE: / 'Abbruch.'.
  ENDIF.

[ABAP] Charts mit cl_gui_chart_engine / cl_gui_chart_engine_win anzeigen, ändern, laden und speichern (XML), Beispiel-Charts

Einleitung

Mit Hilfe der Klasse cl_gui_chart_engine können Charts generiert werden. Über XML-Dokumente kann die Anzeige konfiguriert bzw. Daten angezeigt werden. SAP liefert zur einfachen Konfiguration ein Tool namens Chart Designer. Die XML-Daten können aber auch manuell generiert werden, eine genaue Beschreibung findet man im Dokument „XML Format.pdf“ des Chart Designers.
Mit Hilfe des unten stehenden Demo-Programms können auch XML-Daten für das Customizing generiert, geladen und gespeichert sowie Plot-Daten im XML-Format eingeladen werden. Es sind auch zwei einfache Beispiele für einen Bar-Chart sowie einen Scatter-Plot implementiert.

ABAP-Demoprogramm

* Chart-Demoprogramme
* GRAPHICS_GUI_CE_DEMO
* GRAPHICS_IGS_CE_TEST
* RSORA_TCS_DEMO

* Chart-Klassen
* CL_GUI_CHART_ENGINE
* CL_IGS_CHART_ENGINE
* CL_TIME_CHART_SIMPLE

DATA: it_sflight TYPE STANDARD TABLE OF sflight.
* globales Chart-Objekt
DATA: o_chart TYPE REF TO cl_gui_chart_engine.

CLASS lcl_events DEFINITION.
  PUBLIC SECTION.

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

* Buttons
    CONSTANTS: co_btn_load_cust TYPE string VALUE 'BTN_LOAD_CUST'.
    CONSTANTS: co_btn_load_data TYPE string VALUE 'BTN_LOAD_DATA'.
    CONSTANTS: co_btn_save_cust TYPE string VALUE 'BTN_SAVE_CUST'.
    CONSTANTS: co_btn_print TYPE string VALUE 'BTN_PRINT'.
    CONSTANTS: co_btn_example_bar TYPE string VALUE 'BTN_EXAMPLE_BAR'.
    CONSTANTS: co_btn_example_scatter TYPE string VALUE 'BTN_EXAMPLE_SCATTER'.
    CONSTANTS: co_btn_clear TYPE string VALUE 'BTN_CLEAR'.

    CLASS-METHODS: on_click FOR EVENT click OF cl_gui_chart_engine
      IMPORTING
          element
          series
          point
          sender.
    CLASS-METHODS: on_value_change FOR EVENT value_change OF cl_gui_chart_engine
      IMPORTING
          series
          point
          value
          sender.
    CLASS-METHODS: on_property_change FOR EVENT property_change OF cl_gui_chart_engine
      IMPORTING
          element
          name
          value
          sender.

    CLASS-METHODS:
      on_function_selected FOR EVENT function_selected OF cl_gui_toolbar
        IMPORTING
            fcode
            sender.
ENDCLASS.

CLASS lcl_events IMPLEMENTATION.
* Klick auf Chart
  METHOD on_click.
    MESSAGE |Klick: { element } { series } { point }| TYPE 'S'.
  ENDMETHOD.

* Chart Wertänderung
  METHOD on_value_change.
    MESSAGE |Wert geändert: { series } { point } { value }| TYPE 'S'.
  ENDMETHOD.

* Chart Property-Änderung
  METHOD on_property_change.
    MESSAGE |Property: { element } { name } { value }| TYPE 'S'.
  ENDMETHOD.

* Toolbar Button geklickt
  METHOD on_function_selected.

    CASE fcode.
* Graph drucken
      WHEN co_btn_print.
        IF o_chart IS BOUND.
          DATA(o_cewp) = CAST cl_gui_chart_engine_win( o_chart->get_control( ) ).
          o_cewp->print( ).
        ENDIF.
* Graph zurücksetzen
      WHEN co_btn_clear.
        IF o_chart IS BOUND.
* Initialdaten setzen
          o_chart->set_data( data = '<?xml version="1.0" encoding="utf-8"?><SimpleChartData></SimpleChartData>' ).
* Initial-Customizing setzen
          o_chart->set_customizing( data = '<?xml version="1.0" encoding="utf-8"?><SAPChartCustomizing version="2.0"></SAPChartCustomizing>' ).
        ENDIF.
**********************************************************************
* Bargraph
* einfaches Balkendiagramm, bei dem jeweils 2 Punkte einer Series
* einer Kategorie zugeordnet werden
**********************************************************************
      WHEN co_btn_example_bar.
        IF o_chart IS BOUND.
* Initialdaten setzen
          o_chart->set_data( data_table = VALUE w3htmltabtype( ( |<?xml version="1.0" encoding="utf-8"?>| )
                                                               ( |<ChartData>| )
                                                               ( |  <Categories>| )
                                                               ( |    <Category>Category 1</Category>| )
                                                               ( |    <Category>Category 2</Category>| )
                                                               ( |    <Category>Category 3</Category>| )
                                                               ( |  </Categories>| )
                                                               ( |  <Series customizing="Series1" label="Series 1">| )
                                                               ( |    <Point>| )
                                                               ( |      <Value type="y">5</Value>| )
                                                               ( |    </Point>| )
                                                               ( |    <Point>| )
                                                               ( |      <Value type="y">10</Value>| )
                                                               ( |    </Point>| )
                                                               ( |    <Point>| )
                                                               ( |      <Value type="y">7</Value>| )
                                                               ( |    </Point>| )
                                                               ( |  </Series>| )
                                                               ( |  <Series customizing="Series2" label="Series 2">| )
                                                               ( |    <Point>| )
                                                               ( |      <Value type="y">7</Value>| )
                                                               ( |    </Point>| )
                                                               ( |    <Point>| )
                                                               ( |      <Value type="y">9</Value>| )
                                                               ( |    </Point>| )
                                                               ( |    <Point>| )
                                                               ( |      <Value type="y">23</Value>| )
                                                               ( |    </Point>| )
                                                               ( |  </Series>| )
                                                               ( |</ChartData>| ) ) ).
* Initial-Customizing setzen
          o_chart->set_customizing( data_table = VALUE w3htmltabtype( ( |<?xml version="1.0" encoding="utf-8"?>| )
                                                                      ( |<SAPChartCustomizing version="2.0">| )
                                                                      ( | <GlobalSettings>| )
                                                                      ( |  <Defaults>| )
                                                                      ( |   <ChartType>Columns</ChartType>| )
                                                                      ( |   <FontFamily>Arial</FontFamily>| )
                                                                      ( |  </Defaults>| )
                                                                      ( | </GlobalSettings>| )
                                                                      ( | <Elements>| )
                                                                      ( |  <ChartElements>| )
                                                                      ( |   <Title>| )
                                                                      ( |    <Caption>Bargraph</Caption>| )
                                                                      ( |   </Title>| )
                                                                      ( |  </ChartElements>| )
                                                                      ( | </Elements>| )
                                                                      ( |</SAPChartCustomizing>| ) ) ).
        ENDIF.
**********************************************************************
* Scatterplot
* x,y-Punkte-Diagramm mit zwei Linien (Series)
* Vorgabe von Achse (min, max), Punkteigenschaften, Farbe, Legende
**********************************************************************
      WHEN co_btn_example_scatter.
        IF o_chart IS BOUND.
* Initialdaten setzen
          o_chart->set_data( data_table = VALUE w3htmltabtype( ( |<?xml version="1.0" encoding="utf-8"?>| )
                                                               ( |<ChartData>| )
                                                               ( |  <Series customizing="Series1" label="y1">| )
                                                               ( |    <Point label="P1">| )
                                                               ( |      <Value type="x">-5.1</Value>| )
                                                               ( |      <Value type="y">-2.3</Value>| )
                                                               ( |    </Point>| )
                                                               ( |    <Point label="P2">| )
                                                               ( |      <Value type="x">1.2</Value>| )
                                                               ( |      <Value type="y">1.1</Value>| )
                                                               ( |    </Point>| )
                                                               ( |    <Point label="P3">| )
                                                               ( |      <Value type="x">6.2</Value>| )
                                                               ( |      <Value type="y">7.4</Value>| )
                                                               ( |    </Point>| )
                                                               ( |  </Series>| )
                                                               ( |  <Series customizing="Series2" label="y2">| )
                                                               ( |    <Point label="P1">| )
                                                               ( |      <Value type="x">-5.1</Value>| )
                                                               ( |      <Value type="y">0.3</Value>| )
                                                               ( |    </Point>| )
                                                               ( |    <Point label="P2">| )
                                                               ( |      <Value type="x">1.2</Value>| )
                                                               ( |      <Value type="y">3.5</Value>| )
                                                               ( |    </Point>| )
                                                               ( |    <Point label="P3">| )
                                                               ( |      <Value type="x">6.2</Value>| )
                                                               ( |      <Value type="y">8.9</Value>| )
                                                               ( |    </Point>| )
                                                               ( |  </Series>| )
                                                               ( |</ChartData>| ) ) ).
* Initial-Customizing setzen
          o_chart->set_customizing( data_table = VALUE w3htmltabtype( ( |<?xml version="1.0" encoding="utf-8"?>| )
                                                                      ( |<SAPChartCustomizing version="2.0">| )
                                                                      ( | <GlobalSettings>| )
                                                                      ( |  <Dimension>Two</Dimension>| )
                                                                      ( |  <ColorPalette>Tradeshow</ColorPalette>| )
                                                                      ( |  <Defaults>| )
                                                                      ( |   <ChartType>Scatter</ChartType>| )
                                                                      ( |   <FontFamily>Arial</FontFamily>| )
                                                                      ( |  </Defaults>| )
                                                                      ( | </GlobalSettings>| )
                                                                      ( | <Elements>| )
                                                                      ( |  <ChartElements>| )
                                                                      ( |   <Title>| )
                                                                      ( |    <Caption>Scatterplot</Caption>| )
                                                                      ( |   </Title>| )
                                                                      ( |   <Subtitle>| )
                                                                      ( |    <Caption>Daten und Settings</Caption>| )
                                                                      ( |   </Subtitle>| )
                                                                      ( |   <Legend>| )
                                                                      ( |    <Alignment>ToPlotArea</Alignment>| )
                                                                      ( |    <Position>TopRight</Position>| )
                                                                      ( |   </Legend>| )
                                                                      ( |  </ChartElements>| )
                                                                      ( |  <ChartAxes>| )
                                                                      ( |   <ValueAxis id="ValueAxis1">| )
                                                                      ( |    <Visibility>true</Visibility>| )
                                                                      ( |    <Minimum>-10</Minimum>| )
                                                                      ( |    <MinimumCalculation>UserDefined</MinimumCalculation>| )
                                                                      ( |    <Maximum>10</Maximum>| )
                                                                      ( |    <MaximumCalculation>UserDefined</MaximumCalculation>| )
                                                                      ( |    <ScalingType>Linear</ScalingType>| )
                                                                      ( |    <Order>Ascending</Order>| )
                                                                      ( |    <Position>Primary</Position>| )
                                                                      ( |    <Title>| )
                                                                      ( |     <Caption>x</Caption>| )
                                                                      ( |    </Title>| )
                                                                      ( |   </ValueAxis>| )
                                                                      ( |   <ValueAxis id="ValueAxis2">| )
                                                                      ( |    <Visibility>true</Visibility>| )
                                                                      ( |    <Minimum>-10</Minimum>| )
                                                                      ( |    <MinimumCalculation>UserDefined</MinimumCalculation>| )
                                                                      ( |    <Maximum>10</Maximum>| )
                                                                      ( |    <MaximumCalculation>UserDefined</MaximumCalculation>| )
                                                                      ( |    <ScalingType>Linear</ScalingType>| )
                                                                      ( |    <Order>Ascending</Order>| )
                                                                      ( |    <Position>Primary</Position>| )
                                                                      ( |    <Title>| )
                                                                      ( |     <Caption>x</Caption>| )
                                                                      ( |    </Title>| )
                                                                      ( |   </ValueAxis>| )
                                                                      ( |  </ChartAxes>| )
                                                                      ( | </Elements>| )
                                                                      ( | <Values>| )
                                                                      ( |  <Series>| )
                                                                      ( |   <ShowLabel>true</ShowLabel>| )
                                                                      ( |   <LineColor>@20</LineColor>| )
                                                                      ( |  </Series>| )
                                                                      ( |  <Series id="Series1">| )
                                                                      ( |   <ShowLabel>true</ShowLabel>| )
                                                                      ( |   <LineColor>@20</LineColor>| )
                                                                      ( |   <Color>@20</Color>| )
                                                                      ( |  </Series>| )
                                                                      ( |  <Series id="Series2">| )
                                                                      ( |   <ShowLabel>true</ShowLabel>| )
                                                                      ( |   <LineColor>@60</LineColor>| )
                                                                      ( |   <Color>@60</Color>| )
                                                                      ( |  </Series>| )
                                                                      ( | </Values>| )
                                                                      ( |</SAPChartCustomizing>| ) ) ).
        ENDIF.
* XML Chart-Customizing speichern
      WHEN co_btn_save_cust.
        IF o_chart IS BOUND.
          DATA: it_xml TYPE w3htmltabtype.

          DATA(o_cew_save) = CAST cl_gui_chart_engine_win( o_chart->get_control( ) ).
          o_cew_save->get_customizing( IMPORTING data_table = it_xml ).

          DATA: lv_action TYPE i.
          DATA: lv_filename TYPE string.
          DATA: lv_fullpath TYPE string.
          DATA: lv_path TYPE string.

          TRY.
* Savedialog anzeigen
              cl_gui_frontend_services=>file_save_dialog( EXPORTING
                                                            default_file_name = 'chart.xml'
                                                            default_extension = 'xml'
                                                            file_filter       = |XML (*.xml)\|*.xml\|{ cl_gui_frontend_services=>filetype_all }|
                                                          CHANGING
                                                            filename          = lv_filename
                                                            path              = lv_path
                                                            fullpath          = lv_fullpath
                                                            user_action       = lv_action ).

              IF lv_action EQ cl_gui_frontend_services=>action_ok.

* XML-Daten lokal speichern
                cl_gui_frontend_services=>gui_download( EXPORTING
                                                          filename = lv_fullpath
                                                          filetype = 'BIN'
                                                        CHANGING
                                                          data_tab = it_xml ).

              ENDIF.
            CATCH cx_root INTO DATA(e_txt).
              MESSAGE e_txt->get_text( ) TYPE 'E'.
          ENDTRY.
        ENDIF.
* XML Chart-Customizing laden
      WHEN co_btn_load_cust.
        IF o_chart IS BOUND.
          DATA: lv_rc_cust TYPE i.
          DATA: it_files_cust TYPE filetable.
          DATA: lv_action_open_cust TYPE i.

* FileOpen-Dialog aufrufen
          TRY.
              cl_gui_frontend_services=>file_open_dialog( EXPORTING
                                                            file_filter = |XML (*.xml)\|*.xml\|{ cl_gui_frontend_services=>filetype_all }|
                                                          CHANGING
                                                            file_table  = it_files_cust
                                                            rc          = lv_rc_cust
                                                            user_action = lv_action_open_cust ).

              IF lv_action_open_cust = cl_gui_frontend_services=>action_ok.
* wenn Datei ausgewählt wurde
                IF lines( it_files_cust ) > 0.

                  DATA: lv_filesize_cust TYPE w3param-cont_len.
                  DATA: it_xml_cust_up TYPE w3htmltabtype.

                  cl_gui_frontend_services=>gui_upload( EXPORTING
                                                          filename   = |{ it_files_cust[ 1 ]-filename }|
                                                          filetype   = 'BIN'
                                                        IMPORTING
                                                          filelength = lv_filesize_cust
                                                        CHANGING
                                                          data_tab   = it_xml_cust_up ).

* XML-Daten setzen
                  o_chart->set_customizing( data_table = it_xml_cust_up ).

                ENDIF.
              ENDIF.

            CATCH cx_root INTO DATA(e_text_cust).
              MESSAGE e_text_cust->get_text( ) TYPE 'S' DISPLAY LIKE 'E'.
          ENDTRY.

        ENDIF.
* XML Chart-Daten laden
      WHEN co_btn_load_data.
        IF o_chart IS BOUND.
          DATA: lv_rc_data TYPE i.
          DATA: it_files_data TYPE filetable.
          DATA: lv_action_open_data TYPE i.

* FileOpen-Dialog aufrufen
          TRY.
              cl_gui_frontend_services=>file_open_dialog( EXPORTING
                                                            file_filter = |XML (*.xml)\|*.xml\|{ cl_gui_frontend_services=>filetype_all }|
                                                          CHANGING
                                                            file_table  = it_files_data
                                                            rc          = lv_rc_data
                                                            user_action = lv_action_open_data ).

              IF lv_action_open_data = cl_gui_frontend_services=>action_ok.
* wenn Datei ausgewählt wurde
                IF lines( it_files_data ) > 0.

                  DATA: lv_filesize_data TYPE w3param-cont_len.
                  DATA: it_xml_data_up TYPE w3htmltabtype.

                  cl_gui_frontend_services=>gui_upload( EXPORTING
                                                          filename   = |{ it_files_data[ 1 ]-filename }|
                                                          filetype   = 'BIN'
                                                        IMPORTING
                                                          filelength = lv_filesize_data
                                                        CHANGING
                                                          data_tab   = it_xml_data_up ).

* XML-Daten setzen
                  o_chart->set_data( data_table = it_xml_data_up ).

                ENDIF.
              ENDIF.

            CATCH cx_root INTO DATA(e_text_data).
              MESSAGE e_text_data->get_text( ) TYPE 'S' DISPLAY LIKE 'E'.
          ENDTRY.

        ENDIF.
    ENDCASE.
  ENDMETHOD.
ENDCLASS.

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

* absoluter Modus für Zeilenhöhe
  o_splitter->set_row_mode( mode = cl_gui_splitter_container=>mode_absolute ).

* Höhe absolut 24 Pixel für Splitter oben
  o_splitter->set_row_height( id = 1 height = 24 ).

* Splitter für oberen Container fest und verborgen
  o_splitter->set_row_sash( id = 1
                            type = cl_gui_splitter_container=>type_movable
                            value = cl_gui_splitter_container=>false ).

  o_splitter->set_row_sash( id = 1
                            type = cl_gui_splitter_container=>type_sashvisible
                            value = cl_gui_splitter_container=>false ).

* Top- und Bottom-Container holen
  DATA(o_container_top) = o_splitter->get_container( row = 1 column = 1 ).
  DATA(o_container_bottom) = o_splitter->get_container( row = 2 column = 1 ).

* Toolbar hoizontal
  DATA(o_tool) = NEW cl_gui_toolbar( parent       = o_container_top
                                     display_mode = cl_gui_toolbar=>m_mode_horizontal ).

* Eventtypten müssen gesondert registriert werden
  DATA(it_events) = VALUE lcl_events=>ty_it_events( ( eventid    = cl_gui_toolbar=>m_id_function_selected
                                                      appl_event = abap_true ) ).

  o_tool->set_registered_events( events = it_events ).

* Toolbar-Buttons hinzufügen
* Buttontypen sind in Typgruppe CNTB definiert
  o_tool->add_button( fcode       = CONV #( lcl_events=>co_btn_load_cust )
                      icon        = icon_open
                      butn_type   = cntb_btype_button
                      text        = 'Load settings'
                      quickinfo   = 'Load chart settings'
                      is_checked  = abap_false
                      is_disabled = abap_false ).

  o_tool->add_button( fcode       = ''
                      icon        = ''
                      butn_type   = cntb_btype_sep
                      text        = ''
                      quickinfo   = ''
                      is_checked  = abap_false
                      is_disabled = abap_false ).

  o_tool->add_button( fcode       = CONV #( lcl_events=>co_btn_save_cust )
                      icon        = icon_system_save
                      butn_type   = cntb_btype_button
                      text        = 'Save settings'
                      quickinfo   = 'Save chart settings'
                      is_checked  = abap_false
                      is_disabled = abap_false ).

  o_tool->add_button( fcode       = ''
                      icon        = ''
                      butn_type   = cntb_btype_sep
                      text        = ''
                      quickinfo   = ''
                      is_checked  = abap_false
                      is_disabled = abap_false ).

  o_tool->add_button( fcode       = CONV #( lcl_events=>co_btn_load_data )
                      icon        = icon_open
                      butn_type   = cntb_btype_button
                      text        = 'Load data'
                      quickinfo   = 'Load chart data'
                      is_checked  = abap_false
                      is_disabled = abap_false ).

  o_tool->add_button( fcode       = ''
                      icon        = ''
                      butn_type   = cntb_btype_sep
                      text        = ''
                      quickinfo   = ''
                      is_checked  = abap_false
                      is_disabled = abap_false ).

  o_tool->add_button( fcode       = CONV #( lcl_events=>co_btn_example_bar )
                      icon        = icon_display
                      butn_type   = cntb_btype_button
                      text        = 'Beispiel Bargraph'
                      quickinfo   = 'Beispieldaten + Settings'
                      is_checked  = abap_false
                      is_disabled = abap_false ).

  o_tool->add_button( fcode       = ''
                      icon        = ''
                      butn_type   = cntb_btype_sep
                      text        = ''
                      quickinfo   = ''
                      is_checked  = abap_false
                      is_disabled = abap_false ).

  o_tool->add_button( fcode       = CONV #( lcl_events=>co_btn_example_scatter )
                      icon        = icon_display
                      butn_type   = cntb_btype_button
                      text        = 'Beispiel Scatterplot'
                      quickinfo   = 'Beispieldaten + Settings'
                      is_checked  = abap_false
                      is_disabled = abap_false ).

  o_tool->add_button( fcode       = ''
                      icon        = ''
                      butn_type   = cntb_btype_sep
                      text        = ''
                      quickinfo   = ''
                      is_checked  = abap_false
                      is_disabled = abap_false ).

  o_tool->add_button( fcode       = CONV #( lcl_events=>co_btn_clear )
                      icon        = icon_delete
                      butn_type   = cntb_btype_button
                      text        = 'Löschen'
                      quickinfo   = 'Alles löschen'
                      is_checked  = abap_false
                      is_disabled = abap_false ).

  o_tool->add_button( fcode       = ''
                      icon        = ''
                      butn_type   = cntb_btype_sep
                      text        = ''
                      quickinfo   = ''
                      is_checked  = abap_false
                      is_disabled = abap_false ).

  o_tool->add_button( fcode       = CONV #( lcl_events=>co_btn_print )
                      icon        = icon_print
                      butn_type   = cntb_btype_button
                      text        = 'Drucken'
                      quickinfo   = 'Chart drucken'
                      is_checked  = abap_false
                      is_disabled = abap_false ).

* Eventhandler registrieren
  SET HANDLER lcl_events=>on_function_selected FOR o_tool.

**********************************************************************
* Chart
**********************************************************************
* Daten holen
  SELECT * FROM sflight INTO TABLE it_sflight UP TO 10 ROWS.

* Chart in unteren GUI-Container einbetten
  o_chart = NEW #( parent = o_container_bottom ).

**********************************************************************
* Chart-Daten generieren
**********************************************************************
* leere Defaultdaten übergeben
  DATA(it_xml_data) = VALUE w3htmltabtype( ).
  o_chart->set_data( data_table = it_xml_data ).

**********************************************************************
* Chart-Customizing generieren
**********************************************************************
* leere Defaultdaten übergeben
  DATA(it_xml_customizing) = VALUE w3htmltabtype( ).
  o_chart->set_customizing( data_table = it_xml_customizing ).

**********************************************************************
* zus. Einstellungen
**********************************************************************
* Einstellungsdialoge anzeigen
  DATA(o_adj) = CAST cl_gui_chart_engine_win( o_chart->get_control( ) ).
* Design-Anpassungen ermöglichen
  o_adj->set_design_mode( flag = abap_true event = abap_true ).
* Einstellmöglichkeiten beschränken
*  o_adj->restrict_chart_types( charttypes = 'Columns|Lines' ).
*  o_adj->restrict_property_events( events = 'ChartType' ).

* Wertänderungen ermöglichen
  o_adj->enable_value_change( ).

* Event-Handler registrieren
  SET HANDLER lcl_events=>on_click FOR o_chart.
  SET HANDLER lcl_events=>on_value_change FOR o_chart.
  SET HANDLER lcl_events=>on_property_change FOR o_chart.

* Graph anzeigen
  o_chart->render( ).

* leere Toolbar ausblenden
  cl_abap_list_layout=>suppress_toolbar( ).

* cl_gui_container=>default_screen erzingen
  WRITE: / space.

Weitere XML-Beispiele

Customizing für Scatter-Plot

<?xml version="1.0" encoding="utf-8"?>
<SAPChartCustomizing version="2.0">
 <GlobalSettings>
  <Dimension>Two</Dimension>
  <Defaults>
   <ChartType>Scatter</ChartType>
   <FontFamily>Arial</FontFamily>
  </Defaults>
 </GlobalSettings>
 <Elements>
  <ChartElements>
   <Title>
    <Caption>Beispiel-Titel</Caption>
   </Title>
   <Subtitle>
    <Caption>Untertitel</Caption>
   </Subtitle>
   <Legend>
    <Alignment>ToPlotArea</Alignment>
    <Position>Right</Position>
   </Legend>
  </ChartElements>
  <ChartAxes>
   <ValueAxis id="ValueAxis1">
    <Visibility>true</Visibility>
    <MinimumCalculation>Automatic</MinimumCalculation>
    <MaximumCalculation>Automatic</MaximumCalculation>
    <ScalingType>Linear</ScalingType>
    <Order>Ascending</Order>
    <Position>Primary</Position>
    <Title>
     <Caption>x</Caption>
    </Title>
   </ValueAxis>
  </ChartAxes>
 </Elements>
</SAPChartCustomizing>

Daten für Scatter-Plot

<?xml version="1.0" encoding="utf-8"?>
<ChartData>
  <Categories>
    <Category>Category 1</Category>
  </Categories>
  <Series customizing="Series1" label="y">
    <Point label="P1">
      <Value type="x">0</Value>
      <Value type="y">5</Value>
    </Point>
    <Point label="P2">
      <Value type="x">1</Value>
      <Value type="y">10</Value>
    </Point>
    <Point label="P3">
      <Value type="x">2</Value>
      <Value type="y">7</Value>
    </Point>
  </Series>
</ChartData>

Customizing für Bar-Chart

<?xml version="1.0" encoding="utf-8"?>
<SAPChartCustomizing version="2.0">
 <GlobalSettings>
  <Defaults>
   <ChartType>Columns</ChartType>
   <FontFamily>Arial</FontFamily>
  </Defaults>
 </GlobalSettings>
 <Elements>
  <ChartElements>
   <Title>
    <Visibility>true</Visibility>
    <Caption>Caption1</Caption>
   </Title>
  </ChartElements>
 </Elements>
</SAPChartCustomizing>

Daten für Bar-Chart

<?xml version="1.0" encoding="utf-8"?>
<ChartData>
  <Categories>
    <Category>Category 1</Category>
    <Category>Category 2</Category>
    <Category>Category 3</Category>
  </Categories>
  <Series customizing="Series1" label="Series 1">
    <Point>
      <Value type="y">5</Value>
    </Point>
    <Point>
      <Value type="y">10</Value>
    </Point>
    <Point>
      <Value type="y">7</Value>
    </Point>
  </Series>
  <Series customizing="Series2" label="Series 2">
    <Point>
      <Value type="y">7</Value>
    </Point>
    <Point>
      <Value type="y">9</Value>
    </Point>
    <Point>
      <Value type="y">23</Value>
    </Point>
  </Series>
</ChartData>

Weiterführende Infos

Easy Charts
Creating Charts
abapblog.com
catmull rom
Custom Chart Creation

[ABAP] SALV-Table in der Listausgabe in Custom-Container anzeigen

DATA: o_alv TYPE REF TO cl_salv_table.

START-OF-SELECTION.
  DATA: it_spfli TYPE STANDARD TABLE OF spfli WITH DEFAULT KEY.

  SELECT * FROM spfli INTO CORRESPONDING FIELDS OF TABLE it_spfli.

  WRITE: / 'GUI-Objekt in der Listanzeige'.

  ULINE.

* freier Custom-Container in der Listenansicht
  DATA(o_cnt) = NEW cl_gui_custom_container( container_name = ''
                                             repid          = 'SAPMSSY0'
                                             dynnr          = '0120' ).
* Position des Containers
  o_cnt->set_top( 50 ).
  o_cnt->set_left( 50 ).
  o_cnt->set_width( 1000 ).
  o_cnt->set_height( 200 ).


* SALV-Grid für Anzeige im Container
  TRY.
      cl_salv_table=>factory( EXPORTING
                                r_container  = o_cnt
                              IMPORTING
                                r_salv_table = o_alv
                              CHANGING
                                t_table      = it_spfli ).

      o_alv->display( ).

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

  DO 100 TIMES.
    WRITE: / |{ sy-index } Lorem ipsum.|.
  ENDDO.