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