[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] ABAP2XLSX: Interne Tabelle als Excel-Datei (*.xlsx) aufbereiten und mit Desktop Office Integration (DOI) als Excel inplace anzeigen

Variante 1 (Daten aus der Tabelle SFLIGHT anzeigen)

* 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.

* Daten holen
  SELECT * FROM sflight INTO TABLE @DATA(it_sflight).

  TRY.
* ABAP2XLSX
      DATA: o_xl TYPE REF TO zcl_excel.

* Converter itab->ABAP2XLSX
      DATA(o_converter) = NEW zcl_excel_converter( ).

      o_converter->convert( EXPORTING
                              it_table = it_sflight
                            CHANGING
                              co_excel = o_xl ).

* aktive Worksheet
      DATA(o_xl_ws) = o_xl->get_active_worksheet( ).
* oberste Zeile einfrieren -> beim Scrollen immer sichtbar
      o_xl_ws->freeze_panes( ip_num_rows = 1 ).

* Binärdaten (xstring) generieren
      DATA(o_xlwriter) = CAST zif_excel_writer( NEW zcl_excel_writer_2007( ) ).
      DATA(lv_xl_xdata) = o_xlwriter->write_file( o_xl ).

* Daten mit DOI (Excel inplace) anzeigen
      DATA: o_oic TYPE REF TO i_oi_container_control.
      DATA: o_oid TYPE REF TO i_oi_document_proxy.
      DATA: o_err TYPE REF TO i_oi_error.
      DATA: it_errors TYPE STANDARD TABLE OF REF TO i_oi_error WITH NON-UNIQUE DEFAULT KEY.

      c_oi_container_control_creator=>get_container_control( IMPORTING
                                                               control = o_oic
                                                               error   = o_err ).

      APPEND o_err TO it_errors.

      IF abap_true = o_err->has_succeeded.
        o_oic->init_control( EXPORTING
                               inplace_enabled     = abap_true
                               no_flush            = abap_true
                               r3_application_name = 'Flugverbindungen'
                               parent              = cl_gui_container=>default_screen
                             IMPORTING
                               error               = o_err ).

        APPEND o_err TO it_errors.

        IF abap_true = o_err->has_succeeded.
          o_oic->get_document_proxy( EXPORTING
                                       document_type  = soi_doctype_excel_sheet " 'Excel.Sheet'
                                     IMPORTING
                                       document_proxy = o_oid
                                       error          = o_err ).
          APPEND o_err TO it_errors.

          IF abap_true = o_err->has_succeeded.
            DATA(it_raw) = cl_bcs_convert=>xstring_to_solix( iv_xstring = lv_xl_xdata ).
            DATA(lv_rawlen) = xstrlen( lv_xl_xdata ).

* Binärdaten des *.xlsx im Hintergrund an DOI-Objekt senden und anzeigen
            o_oid->open_document_from_table( EXPORTING
                                               document_size  = lv_rawlen
                                               document_table = it_raw
                                               open_inplace   = abap_true
                                             IMPORTING
                                               error          = o_err ).

            APPEND o_err TO it_errors.

            IF abap_true = o_err->has_succeeded.

* leere Toolbar ausblenden
              cl_abap_list_layout=>suppress_toolbar( ).

* cl_gui_container=>default_screen erzwingen
              CALL SCREEN 100.

* Schließen eines Dokuments in der Office-Anwendung
              o_oid->close_document( IMPORTING error = o_err ).

              APPEND o_err TO it_errors.

              IF o_err->has_succeeded = abap_true.

* Schließen eines Visual-Basic-Dokuments
                o_oid->close_activex_document( IMPORTING error = o_err ).

                APPEND o_err TO it_errors.

                IF o_err->has_succeeded = abap_true.

* Freigabe des für das Dokument reservierten Speichers
                  o_oid->release_document( IMPORTING error = o_err ).

                  APPEND o_err TO it_errors.

                  IF o_err->has_succeeded = abap_true.
                    FREE: o_oid.
                  ENDIF.
                ENDIF.
              ENDIF.
            ENDIF.

* baut das Control ab
            o_oic->destroy_control( IMPORTING error = o_err ).

            APPEND o_err TO it_errors.

            IF o_err->has_succeeded = abap_true.
              FREE: o_oic.
            ENDIF.

          ENDIF.
        ENDIF.
      ENDIF.

* Ausgabe Fehlerprotokoll
      DATA: lv_message_id TYPE sy-msgid.
      DATA: lv_message_number TYPE sy-msgno.
      DATA: lv_param1 TYPE sy-msgv1.
      DATA: lv_param2 TYPE sy-msgv2.
      DATA: lv_param3 TYPE sy-msgv3.
      DATA: lv_param4 TYPE sy-msgv4.

      LOOP AT it_errors ASSIGNING FIELD-SYMBOL(<e>).
        <e>->get_message( IMPORTING
                            message_id     = lv_message_id
                            message_number = lv_message_number
                            param1         = lv_param1
                            param2         = lv_param2
                            param3         = lv_param3
                            param4         = lv_param4
                        ).
        WRITE: / <e>->error_code, lv_message_id, lv_message_number, lv_param1, lv_param2, lv_param3, lv_param4.
      ENDLOOP.

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

Variante 2 (Daten aus der Tabelle SFLIGHT anzeigen, Styles festlegen)

* 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.

* Daten holen
  SELECT * FROM sflight INTO TABLE @DATA(it_sflight).

  TRY.
* ABAP2XLSX
      DATA(o_xl) = NEW zcl_excel( ).
* aktive Worksheet
      DATA(o_xl_ws) = o_xl->get_active_worksheet( ).
* Name der Sheet
      o_xl_ws->set_title( ip_title = 'Flights' ).

* Tabelle übergeben und Style festlegen
      o_xl_ws->bind_table( ip_table          = it_sflight
                           is_table_settings = VALUE #(
                                                        table_style      = zcl_excel_table=>builtinstyle_medium2
*                                                  show_row_stripes = abap_true
                                                      )
                         ).

* oberste Zeile einfrieren -> beim Scrollen immer sichtbar
      o_xl_ws->freeze_panes( ip_num_rows = 1 ).

* Binärdaten (xstring) generieren
      DATA(o_xlwriter) = CAST zif_excel_writer( NEW zcl_excel_writer_2007( ) ).
      DATA(lv_xl_xdata) = o_xlwriter->write_file( o_xl ).

* Daten mit DOI (Excel inplace) anzeigen
      DATA: o_oic TYPE REF TO i_oi_container_control.
      DATA: o_oid TYPE REF TO i_oi_document_proxy.
      DATA: o_err TYPE REF TO i_oi_error.
      DATA: it_errors TYPE STANDARD TABLE OF REF TO i_oi_error WITH NON-UNIQUE DEFAULT KEY.

      c_oi_container_control_creator=>get_container_control( IMPORTING
                                                               control = o_oic
                                                               error   = o_err ).

      APPEND o_err TO it_errors.

      IF abap_true = o_err->has_succeeded.
        o_oic->init_control( EXPORTING
                               inplace_enabled     = abap_true
                               no_flush            = abap_true
                               r3_application_name = 'Flugverbindungen'
                               parent              = cl_gui_container=>default_screen
                             IMPORTING
                               error               = o_err ).

        APPEND o_err TO it_errors.

        IF abap_true = o_err->has_succeeded.
          o_oic->get_document_proxy( EXPORTING
                                       document_type  = soi_doctype_excel_sheet " 'Excel.Sheet'
                                     IMPORTING
                                       document_proxy = o_oid
                                       error          = o_err ).

          APPEND o_err TO it_errors.

          IF abap_true = o_err->has_succeeded.
            DATA(it_raw) = cl_bcs_convert=>xstring_to_solix( iv_xstring = lv_xl_xdata ).
            DATA(lv_rawlen) = xstrlen( lv_xl_xdata ).

* Binärdaten des *.xlsx im Hintergrund an DOI-Objekt senden und anzeigen
            o_oid->open_document_from_table( EXPORTING
                                               document_size    = lv_rawlen
                                               document_table   = it_raw
                                               open_inplace     = abap_true
                                             IMPORTING
                                               error          = o_err ).

            APPEND o_err TO it_errors.

            IF abap_true = o_err->has_succeeded.

* leere Toolbar ausblenden
              cl_abap_list_layout=>suppress_toolbar( ).

* cl_gui_container=>default_screen erzwingen
              CALL SCREEN 100.

* Schließen eines Dokuments in der Office-Anwendung
              o_oid->close_document( IMPORTING error = o_err ).

              APPEND o_err TO it_errors.

              IF o_err->has_succeeded = abap_true.

* Schließen eines Visual-Basic-Dokuments
                o_oid->close_activex_document( IMPORTING error = o_err ).

                APPEND o_err TO it_errors.

                IF o_err->has_succeeded = abap_true.

* Freigabe des für das Dokument reservierten Speichers
                  o_oid->release_document( IMPORTING error = o_err ).

                  APPEND o_err TO it_errors.

                  IF o_err->has_succeeded = abap_true.
                    FREE: o_oid.
                  ENDIF.
                ENDIF.
              ENDIF.
            ENDIF.

* baut das Control ab
            o_oic->destroy_control( IMPORTING error = o_err ).

            APPEND o_err TO it_errors.

            IF o_err->has_succeeded = abap_true.
              FREE: o_oic.
            ENDIF.

          ENDIF.
        ENDIF.
      ENDIF.

* Ausgabe Fehlerprotokoll
      DATA: lv_message_id TYPE sy-msgid.
      DATA: lv_message_number TYPE sy-msgno.
      DATA: lv_param1 TYPE sy-msgv1.
      DATA: lv_param2 TYPE sy-msgv2.
      DATA: lv_param3 TYPE sy-msgv3.
      DATA: lv_param4 TYPE sy-msgv4.

      LOOP AT it_errors ASSIGNING FIELD-SYMBOL(<e>).
        <e>->get_message( IMPORTING
                            message_id     = lv_message_id
                            message_number = lv_message_number
                            param1         = lv_param1
                            param2         = lv_param2
                            param3         = lv_param3
                            param4         = lv_param4
                        ).
        WRITE: / <e>->error_code, lv_message_id, lv_message_number, lv_param1, lv_param2, lv_param3, lv_param4.
      ENDLOOP.

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

Variante 3 (Daten aus der Tabelle SFLIGHT anzeigen, Komplexbeispiel)

* 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.

* Daten holen
  SELECT * FROM sflight INTO TABLE @DATA(it_sflight).

  TRY.
* ABAP2XLSX
      DATA(o_xl) = NEW zcl_excel( ).
* aktive Worksheet
      DATA(o_xl_ws) = o_xl->get_active_worksheet( ).
* Name der Sheet
      o_xl_ws->set_title( ip_title = 'Flights' ).
* Gitterlinien ausschalten
      o_xl_ws->set_show_gridlines( i_show_gridlines = abap_false ).
* oberste zwei Zeilen einfrieren -> beim Scrollen immer sichtbar
      o_xl_ws->freeze_panes( ip_num_rows = 2 ).

* RTTS: Table: Beschreibung
      DATA(o_tdesc) = CAST cl_abap_tabledescr( cl_abap_tabledescr=>describe_by_data( it_sflight ) ).
* RTTS: Row: Beschreibung
      DATA(o_sdesc) = CAST cl_abap_structdescr( o_tdesc->get_table_line_type( ) ).
* RTTS: Col: Komponenten (Felder) -> DFIES: DD-Schnittstelle: Tabellenfelder für DDIF_FIELDINFO_GET
      DATA(it_com) = o_sdesc->get_components( ).

* Header einfügen
      LOOP AT it_com ASSIGNING FIELD-SYMBOL(<c>).
        DATA(lv_col_head) = sy-tabix.
* Prüfen, ob DDIC-Typ, damit die Metadaten ausgelesen werden können
        DATA(o_edesc_head) = CAST cl_abap_elemdescr( <c>-type ).
        IF o_edesc_head->is_ddic_type( ) EQ abap_true.
          DATA(lv_dfies_head) = o_edesc_head->get_ddic_field( ).
* technischer Name in die erste Zeile
          o_xl_ws->set_cell( ip_column = lv_col_head
                             ip_row    = 1
                             ip_value  = <c>-name ).
* Langtext des Feldes in die zweite Zeile
          o_xl_ws->set_cell( ip_column = lv_col_head
                             ip_row    = 2
                             ip_value  = lv_dfies_head-scrtext_l ).

* Spaltenbreite setzen
          o_xl_ws->get_column( lv_col_head )->set_width( strlen( lv_dfies_head-scrtext_l ) + 5 ).
        ENDIF.

      ENDLOOP.

* Daten einfügen
      LOOP AT it_sflight ASSIGNING FIELD-SYMBOL(<row>).
        DATA(lv_row) = sy-tabix + 2.

        LOOP AT it_com ASSIGNING FIELD-SYMBOL(<col>).
          DATA(lv_col) = sy-tabix.

* Prüfen, ob DDIC-Typ, damit die Metadaten ausgelesen werden können
          DATA(o_edesc) = CAST cl_abap_elemdescr( <col>-type ).
          IF o_edesc->is_ddic_type( ) EQ abap_true.
* wenn DDIC-Typ, dann Metainformationen auslesen
            DATA(lv_dfies) = o_edesc->get_ddic_field( ).
* anhand des Komponentennamens den akt. Zellinhalt einer Zeile lesen
            ASSIGN COMPONENT <col>-name OF STRUCTURE <row> TO FIELD-SYMBOL(<cell>).
            IF <cell> IS ASSIGNED.
              o_xl_ws->set_cell( ip_column = lv_col
                                 ip_row    = lv_row
                                 ip_value  = <cell> ).
            ENDIF.
          ENDIF.
        ENDLOOP.

* Zeilenhöhe
        o_xl_ws->get_row( ip_row = lv_row )->set_row_height( 15 ).
      ENDLOOP.

* Autofilter setzen
      DATA(o_autofilter) = o_xl->add_new_autofilter( io_sheet = o_xl_ws ).
      o_autofilter->set_filter_area( is_area = VALUE #( row_start = 2
                                                        col_start = 1
                                                        row_end   = o_xl_ws->get_highest_row( )
                                                        col_end   = o_xl_ws->get_highest_column( ) ) ).

* Binärdaten (xstring) generieren
      DATA(o_xlwriter) = CAST zif_excel_writer( NEW zcl_excel_writer_2007( ) ).
      DATA(lv_xl_xdata) = o_xlwriter->write_file( o_xl ).

* Daten mit DOI (Excel inplace) anzeigen
      DATA: o_oic TYPE REF TO i_oi_container_control.
      DATA: o_oid TYPE REF TO i_oi_document_proxy.
      DATA: o_err TYPE REF TO i_oi_error.
      DATA: it_errors TYPE STANDARD TABLE OF REF TO i_oi_error WITH NON-UNIQUE DEFAULT KEY.

      c_oi_container_control_creator=>get_container_control( IMPORTING
                                                               control = o_oic
                                                               error   = o_err ).

      APPEND o_err TO it_errors.

      IF abap_true = o_err->has_succeeded.
        o_oic->init_control( EXPORTING
                               inplace_enabled     = abap_true
                               no_flush            = abap_true
                               r3_application_name = 'Flugverbindungen'
                               parent              = cl_gui_container=>default_screen
                             IMPORTING
                               error               = o_err ).

        APPEND o_err TO it_errors.

        IF abap_true = o_err->has_succeeded.
          o_oic->get_document_proxy( EXPORTING
                                       document_type  = soi_doctype_excel_sheet " 'Excel.Sheet'
                                     IMPORTING
                                       document_proxy = o_oid
                                       error          = o_err ).

          APPEND o_err TO it_errors.

          IF abap_true = o_err->has_succeeded.
            DATA(it_raw) = cl_bcs_convert=>xstring_to_solix( iv_xstring = lv_xl_xdata ).
            DATA(lv_rawlen) = xstrlen( lv_xl_xdata ).

* Binärdaten des *.xlsx im Hintergrund an DOI-Objekt senden und anzeigen
            o_oid->open_document_from_table( EXPORTING
                                               document_size  = lv_rawlen
                                               document_table = it_raw
                                               open_inplace   = abap_true
                                             IMPORTING
                                               error          = o_err ).

            APPEND o_err TO it_errors.

            IF abap_true = o_err->has_succeeded.
* leere Toolbar ausblenden
              cl_abap_list_layout=>suppress_toolbar( ).

* cl_gui_container=>default_screen erzwingen
              CALL SCREEN 100.

* Schließen eines Dokuments in der Office-Anwendung
              o_oid->close_document( IMPORTING error = o_err ).

              APPEND o_err TO it_errors.

              IF o_err->has_succeeded = abap_true.

* Schließen eines Visual-Basic-Dokuments
                o_oid->close_activex_document( IMPORTING error = o_err ).

                APPEND o_err TO it_errors.

                IF o_err->has_succeeded = abap_true.

* Freigabe des für das Dokument reservierten Speichers
                  o_oid->release_document( IMPORTING error = o_err ).

                  APPEND o_err TO it_errors.

                  IF o_err->has_succeeded = abap_true.
                    FREE: o_oid.
                  ENDIF.
                ENDIF.
              ENDIF.
            ENDIF.

* baut das Control ab
            o_oic->destroy_control( IMPORTING error = o_err ).

            APPEND o_err TO it_errors.

            IF o_err->has_succeeded = abap_true.
              FREE: o_oic.
            ENDIF.

          ENDIF.
        ENDIF.
      ENDIF.

* Ausgabe Fehlerprotokoll
      DATA: lv_message_id TYPE sy-msgid.
      DATA: lv_message_number TYPE sy-msgno.
      DATA: lv_param1 TYPE sy-msgv1.
      DATA: lv_param2 TYPE sy-msgv2.
      DATA: lv_param3 TYPE sy-msgv3.
      DATA: lv_param4 TYPE sy-msgv4.

      LOOP AT it_errors ASSIGNING FIELD-SYMBOL(<e>).
        <e>->get_message( IMPORTING
                            message_id     = lv_message_id
                            message_number = lv_message_number
                            param1         = lv_param1
                            param2         = lv_param2
                            param3         = lv_param3
                            param4         = lv_param4
                        ).
        WRITE: / <e>->error_code, lv_message_id, lv_message_number, lv_param1, lv_param2, lv_param3, lv_param4.
      ENDLOOP.

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

[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] GUI-Toolbar mit dynamischen Context-Menü, Eventhandling, Umschaltung checked-state

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

TYPES: BEGIN OF ty_menuitem,
         fcode   TYPE ui_func,
         checked TYPE cua_active,
         text    TYPE gui_text,
       END OF ty_menuitem.

TYPES: ty_it_menuitems TYPE STANDARD TABLE OF ty_menuitem WITH DEFAULT KEY.

DATA: it_menuitems TYPE ty_it_menuitems.

CLASS lcl_events DEFINITION.
  PUBLIC SECTION.
    CLASS-METHODS:
      on_function_selected FOR EVENT function_selected OF cl_gui_toolbar
        IMPORTING
            fcode
            sender.
    CLASS-METHODS:
      on_dropdown_clicked FOR EVENT dropdown_clicked OF cl_gui_toolbar
        IMPORTING
            fcode
            posx
            posy
            sender.
ENDCLASS.

CLASS lcl_events IMPLEMENTATION.
* Toolbar: Button oder Menüpunktgeklickt
  METHOD on_function_selected.

* Checked-Status eines Dropdown-Menüpunktes umschalten
    IF line_exists( it_menuitems[ fcode = fcode ] ).
      ASSIGN it_menuitems[ fcode = fcode ] TO FIELD-SYMBOL(<mc>).
      <mc>-checked = COND #( WHEN <mc>-checked = abap_true THEN abap_false ELSE abap_true ).
    ENDIF.

* Funktionscode auswerten
    CASE fcode.
      WHEN 'BTN_CLOSE'.
        LEAVE PROGRAM.
      WHEN 'BTN_DROP'.
      WHEN 'M1'.
      WHEN 'M2'.
    ENDCASE.

* fcode ausgeben
    MESSAGE fcode TYPE 'S'.

  ENDMETHOD.
* Toolbar: Dropdown aktiviert
  METHOD on_dropdown_clicked.
* Menü erzeugen
    DATA(o_ctx_menu) = NEW cl_ctmenu( ).

    LOOP AT it_menuitems ASSIGNING FIELD-SYMBOL(<m>).
      o_ctx_menu->add_function( fcode   = <m>-fcode
                                checked = <m>-checked
                                text    = <m>-text ).
    ENDLOOP.

* Kontextmenü an der akt. Position anzeigen
    sender->track_context_menu( context_menu = o_ctx_menu
                                posx         = posx
                                posy         = posy ).
  ENDMETHOD.
ENDCLASS.

INITIALIZATION.

  it_menuitems = VALUE #( ( fcode   = 'M1'
                            checked = abap_false
                            text    = 'Punkt1' )
                          ( fcode   = 'M2'
                            checked = abap_true
                            text    = 'Punkt2' ) ).

* 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 ).

  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 ty_it_events( ( eventid = cl_gui_toolbar=>m_id_function_selected
                                          appl_event = abap_true )
                                        ( eventid = cl_gui_toolbar=>m_id_dropdown_clicked
                                          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       = 'BTN_DROP'
                      icon        = icon_activate
                      butn_type   = cntb_btype_dropdown
                      text        = 'Menü'
                      quickinfo   = 'Menü anzeigen'
                      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       = 'BTN_CLOSE'
                      icon        = icon_close
                      butn_type   = cntb_btype_button
                      text        = 'Schließen'
                      quickinfo   = 'Schließen'
                      is_checked  = abap_false
                      is_disabled = abap_false ).

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

* im unteren 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_bottom
                          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.

Weiterführender Link zur Ideen-Quelle: Link

[ABAP] Eigene GUI-Toolbar in einem Split-Container anzeigen, Eventhandling

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

CLASS lcl_events DEFINITION.
  PUBLIC SECTION.
    CLASS-METHODS:
      on_function_selected FOR EVENT function_selected OF cl_gui_toolbar
        IMPORTING
            fcode
            sender.
ENDCLASS.

CLASS lcl_events IMPLEMENTATION.
* Toolbar Button geklickt
  METHOD on_function_selected.

    CASE fcode.
      WHEN 'BTN_CLOSE'.
        LEAVE PROGRAM.
      WHEN 'BTN_TEST'.
        MESSAGE 'TEST' TYPE 'I' DISPLAY LIKE 'S'.
    ENDCASE.

  ENDMETHOD.

ENDCLASS.

INITIALIZATION.

* 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 ).

  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 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       = 'BTN_TEST'
                      icon        = icon_activate
                      butn_type   = cntb_btype_button
                      text        = 'Test'
                      quickinfo   = 'Test'
                      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       = 'BTN_CLOSE'
                      icon        = icon_close
                      butn_type   = cntb_btype_button
                      text        = 'Schließen'
                      quickinfo   = 'Schließen'
                      is_checked  = abap_false
                      is_disabled = abap_false ).

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

* im unteren 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_bottom
                          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.

[ABAP] Splitter (cl_gui_splitter_container) fixieren und dessen absolute Höhe festlegen

INITIALIZATION.

* 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 40 Pixel für Splitter oben
  o_splitter->set_row_height( id = 1 height = 40 ).

* 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 ).

  DATA(o_container_top) = o_splitter->get_container( row = 1 column = 1 ).
  DATA(o_container_bottom) = o_splitter->get_container( row = 2 column = 1 ).
  
  ...

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