[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] SALV IDA: Funktionsbutton einfügen

DATA: o_alv TYPE REF TO if_salv_gui_table_ida.

CLASS lcl_events DEFINITION.
  PUBLIC SECTION.
* Konstante für Button-Event
    CONSTANTS: co_btn_showdetail type UI_FUNC VALUE 'SHOW_DETAIL'.

    CLASS-METHODS: on_toolbar_function_selected FOR EVENT function_selected OF if_salv_gui_toolbar_ida
      IMPORTING
          ev_fcode
          sender.
ENDCLASS.

CLASS lcl_events IMPLEMENTATION.

  METHOD on_toolbar_function_selected.
    DATA: lv_row TYPE sflight.

    CASE ev_fcode.
* wenn Button-Funktion
      WHEN co_btn_showdetail.

        IF abap_true = o_alv->selection( )->is_row_selected( ).
* ganzen Datensatz holen
          o_alv->selection( )->get_selected_row( EXPORTING
                                                   iv_request_type = if_salv_gui_selection_ida=>cs_request_type-all_fields
                                                 IMPORTING
                                                   es_row = lv_row ).
* Datensatz anzeigen
          cl_salv_ida_show_data_row=>display( iv_text = 'Flug-Details'
                                              is_data = lv_row ).
        ENDIF.
    ENDCASE.
  ENDMETHOD.

ENDCLASS.

START-OF-SELECTION.

  o_alv = cl_salv_gui_table_ida=>create( iv_table_name = 'SFLIGHT' ).

* Single-Selection
  o_alv->selection( )->set_selection_mode( if_salv_gui_selection_ida=>cs_selection_mode-single ).

* Toolbar button einfügen
  o_alv->toolbar( )->add_button( EXPORTING
                                   iv_fcode                     = lcl_events=>co_btn_showdetail
                                   iv_icon                      = icon_flight
                                   iv_text                      = 'Details'
                                   iv_quickinfo                 = 'Flug-Details'
                                   iv_before_standard_functions = abap_true ).
* Separator
  o_alv->toolbar( )->add_separator( EXPORTING
                                      iv_before_standard_functions = abap_true ).

* Event-handler
  SET HANDLER lcl_events=>on_toolbar_function_selected FOR o_alv->toolbar( ).

* Tabelle anzeigen
  o_alv->fullscreen( )->display( ).

[ABAP] Ein SALV-Table IDA und ein GUI-Picture in einem Dockingcontainer direkt auf dem Selektionsbildschirm anzeigen

DATA: o_cnt_bottom TYPE REF TO cl_gui_docking_container.
DATA: o_cnt_right TYPE REF TO cl_gui_docking_container.
DATA: o_alv_bottom TYPE REF TO if_salv_gui_table_ida.
DATA: o_pic TYPE REF TO cl_gui_picture.
DATA: o_collector_bottom TYPE REF TO cl_salv_range_tab_collector.
DATA: lv_mtart TYPE mara-mtart.

SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE title2.
SELECT-OPTIONS: s_mtart FOR lv_mtart.
SELECTION-SCREEN END OF BLOCK b1.

AT SELECTION-SCREEN OUTPUT.

* Verhindern, dass der Container mehrfach erzeugt wird, wenn der Focus aus
* best. Oberflächenelementen zurück kommt.

* Container unten erzeugen
  IF NOT o_cnt_bottom IS BOUND.
    o_cnt_bottom = NEW #( repid = sy-repid
                          dynnr = sy-dynnr
                          side  = cl_gui_docking_container=>dock_at_bottom " unterer Bildschirmrand
                          extension = 300 ).                               " 300 hoch, damit die Selektionskriterien nicht überdeckt werden
* Container rechts erzeugen

    o_cnt_right = NEW #( repid = sy-repid
                         dynnr = sy-dynnr
                         side  = cl_gui_docking_container=>dock_at_right  " rechter Bildschirmrand
                         extension = 800 ).                               " 800 breit, damit die Selektionskriterien nicht überdeckt werden

* IDA-Grid unten erzeugen
    o_alv_bottom = cl_salv_gui_table_ida=>create( iv_table_name    = 'MARA'
                                                  io_gui_container = o_cnt_bottom ).
    o_alv_bottom->display_options( )->set_title( 'MARA' ).

* Picture rechts erzeugen
    o_pic = NEW #( parent = o_cnt_right ).
    o_pic->set_display_mode( display_mode = cl_gui_picture=>display_mode_normal_center ).
    o_pic->load_picture_from_sap_icons( icon  = icon_delete ).

* Suchkriterien unten setzen
    o_collector_bottom = NEW #( ).
    o_collector_bottom->add_ranges_for_name( iv_name = 'MTART' it_ranges = s_mtart[] ).
    o_collector_bottom->get_collected_ranges( IMPORTING et_named_ranges = DATA(it_name_range_pairs_bottom) ).

    o_alv_bottom->set_select_options( it_ranges = it_name_range_pairs_bottom ).
  ENDIF.

[ABAP] Zwei SALV-Table IDA in einem Dockingcontainer direkt auf dem Selektionsbildschirm anzeigen

DATA: o_cnt_bottom TYPE REF TO cl_gui_docking_container.
DATA: o_cnt_right TYPE REF TO cl_gui_docking_container.
DATA: o_alv_bottom TYPE REF TO if_salv_gui_table_ida.
DATA: o_alv_right TYPE REF TO if_salv_gui_table_ida.
DATA: o_collector_bottom TYPE REF TO cl_salv_range_tab_collector.
DATA: o_collector_right TYPE REF TO cl_salv_range_tab_collector.

DATA: lv_arbgb TYPE t100-arbgb.
DATA: lv_msg TYPE t100-msgnr.
DATA: lv_text TYPE t100-text.
DATA: lv_mtart TYPE mara-mtart.

* Selektionskriterien für T100
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE title1.
SELECT-OPTIONS: s_langu FOR sy-langu.
SELECT-OPTIONS: s_arbgb FOR lv_arbgb.
SELECT-OPTIONS: s_msg FOR lv_msg.
SELECT-OPTIONS: s_text FOR lv_text.
SELECTION-SCREEN END OF BLOCK b1.

* Selektionskriterien für MARA
SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE title2.
SELECT-OPTIONS: s_mtart FOR lv_mtart.
SELECTION-SCREEN END OF BLOCK b2.

AT SELECTION-SCREEN OUTPUT.

* Verhindern, dass der Container mehrfach erzeugt wird, wenn der Focus aus
* best. Oberflächenelementen zurück kommt.
  IF NOT o_cnt_bottom IS BOUND.
* Container unten erzeugen
    o_cnt_bottom = NEW #( repid = sy-repid
                          dynnr = sy-dynnr
                          side = cl_gui_docking_container=>dock_at_bottom  " unterer Bildschirmrand
                          extension = 300 ).                               " 300 hoch, damit die Selektionskriterien nicht überdeckt werden

* Container rechts erzeugen
    o_cnt_right = NEW #( repid = sy-repid
                         dynnr = sy-dynnr
                         side = cl_gui_docking_container=>dock_at_right  " rechter Bildschirmrand
                         extension = 800 ).                              " 800 breit, damit die Selektionskriterien nicht überdeckt werden


* IDA-Grid unten erzeugen
    o_alv_bottom = cl_salv_gui_table_ida=>create( iv_table_name    = 'MARA'
                                                  io_gui_container = o_cnt_bottom ).
    o_alv_bottom->display_options( )->set_title( 'MARA' ).

* IDA-Grid rechts erzeugen
    o_alv_right = cl_salv_gui_table_ida=>create( iv_table_name    = 'T100'
                                                 io_gui_container = o_cnt_right ).
    o_alv_right->display_options( )->set_title( 'T100' ).

* Suchkriterien unten setzen
    o_collector_bottom = NEW #( ).
    o_collector_bottom->add_ranges_for_name( iv_name = 'MTART' it_ranges = s_mtart[] ).
    o_collector_bottom->get_collected_ranges( IMPORTING et_named_ranges = DATA(it_name_range_pairs_bottom) ).

    o_alv_bottom->set_select_options( it_ranges = it_name_range_pairs_bottom ).

* Suchkriterien rechts setzen
    o_collector_right = NEW #( ).
    o_collector_right->add_ranges_for_name( iv_name = 'SPRSL' it_ranges = s_langu[] ).
    o_collector_right->add_ranges_for_name( iv_name = 'ARBGB' it_ranges = s_arbgb[] ).
    o_collector_right->add_ranges_for_name( iv_name = 'MSGNR' it_ranges = s_msg[] ).
    o_collector_right->add_ranges_for_name( iv_name = 'TEXT' it_ranges = s_text[] ).
    o_collector_right->get_collected_ranges( IMPORTING et_named_ranges = DATA(it_name_range_pairs_right) ).

    o_alv_right->set_select_options( it_ranges = it_name_range_pairs_right ).
  ENDIF.

[ABAP] SALV-Table IDA in einem Dockingcontainer direkt auf dem Selektionsbildschirm anzeigen

DATA: o_cnt TYPE REF TO cl_gui_docking_container.
DATA: o_alv TYPE REF TO if_salv_gui_table_ida.
DATA: o_collector TYPE REF TO cl_salv_range_tab_collector.
DATA: it_t100 TYPE t100.

SELECT-OPTIONS: s_langu FOR sy-langu.
SELECT-OPTIONS: s_arbgb FOR it_t100-arbgb.
SELECT-OPTIONS: s_msg FOR it_t100-msgnr.
SELECT-OPTIONS: s_text FOR it_t100-text.

AT SELECTION-SCREEN OUTPUT.

* Verhindern, dass der Container mehrfach erzeugt wird, wenn der Focus aus
* best. Oberflächenelementen zurück kommt.
  IF NOT o_cnt IS BOUND.
* Container erzeugen
    o_cnt = NEW #( repid = sy-repid
                   dynnr = sy-dynnr
                   side  = cl_gui_docking_container=>dock_at_bottom " unterer Bildschirmrand
                   extension = 400 ).                               " max. 400 hoch, damit die Selektionskriterien nicht überdeckt werden

* IDA-Grid erzeugen
    o_alv = cl_salv_gui_table_ida=>create( iv_table_name    = 'T100'
                                           io_gui_container = o_cnt ).

    o_collector = NEW #( ).

* Suchkriterien setzen
    o_collector->add_ranges_for_name( iv_name = 'SPRSL' it_ranges = s_langu[] ).
    o_collector->add_ranges_for_name( iv_name = 'ARBGB' it_ranges = s_arbgb[] ).
    o_collector->add_ranges_for_name( iv_name = 'MSGNR' it_ranges = s_msg[] ).
    o_collector->add_ranges_for_name( iv_name = 'TEXT' it_ranges = s_text[] ).
    o_collector->get_collected_ranges( IMPORTING et_named_ranges = DATA(it_name_range_pairs) ).

* IDA-Grid Optionen setzen
    o_alv->set_select_options( it_ranges = it_name_range_pairs ).
    o_alv->display_options( )->enable_alternating_row_pattern( ).
  ENDIF.

[ABAP] SALV IDA: SAP List Viewer with Integrated Data Access

* Beispielprogramme:
* Paket: SALV_IDA_TEST

CONSTANTS: co_table_name TYPE dbtabl VALUE 'SBOOK'.

DATA: lv_carrid TYPE sbook-carrid.

SELECT-OPTIONS: so_carr FOR lv_carrid.

START-OF-SELECTION.

  TRY.
* SALV Table IDA erzeugen
      DATA(o_salv_ida) = cl_salv_gui_table_ida=>create( iv_table_name = co_table_name ).

* Authority Check (löst evtl. Exception aus, wenn Berechtigungen fehlen)
      o_salv_ida->add_authorization_for_object( iv_authorization_object = 'S_CARRID'
                                                it_activities           = VALUE #( ( auth_field = 'ACTVT' value = '03' ) )
                                                it_field_mapping        = VALUE #( ( auth_field = 'CARRID' view_field = 'CARRID' ) ) ).

* SELECT-Konditionen festlegen
      DATA(o_cond_factory) = o_salv_ida->condition_factory( ).

* RANGE definieren: SELECT-OPTIONS
      DATA(o_ranges) = NEW cl_salv_range_tab_collector( ).
      o_ranges->add_ranges_for_name( iv_name = 'CARRID' it_ranges = so_carr[] ).
      o_ranges->get_collected_ranges( IMPORTING
                                        et_named_ranges = DATA(it_name_range_pairs) ).
* RANGE definieren: manuell
      DATA(it_fixed_ranges) = VALUE if_salv_service_types=>yt_named_ranges( ( name = 'FORCURKEY' sign = 'E' option = 'EQ' low = 'GBP' high = '' ) ).

      APPEND LINES OF it_fixed_ranges TO it_name_range_pairs.

* SELECT-Konditionen und RANGES übergeben
      o_salv_ida->set_select_options( it_ranges    = it_name_range_pairs
                                      io_condition = o_cond_factory->equals( name = 'FLDATE' value = '20120523' )->and(
                                                     o_cond_factory->covers_pattern( name = 'PASSNAME' pattern = '*Anna*')->and(
                                                     o_cond_factory->equals( name = 'FORCURKEY' value = 'EUR' )->or(
                                                     o_cond_factory->equals( name = 'FORCURKEY' value = 'USD' ) ) ) ) ).

* Spaltenüberschrift ändern
      o_salv_ida->field_catalog( )->set_field_header_texts( iv_field_name        = 'PASSNAME'
                                                            iv_header_text       = 'Name des Passagiers'
                                                            iv_tooltip_text      = 'Standard: 40 Zeichen zur Verfügung'
                                                            iv_tooltip_text_long = 'Erweiterung: 100 Zeichen zur Verfügung bei richtiger SAP GUI und SAP Basis Version' ).

* Sortierungen festlegen
      DATA(it_sort_order) = VALUE if_salv_gui_types_ida=>yt_sort_rule( ( field_name = 'PASSNAME'
                                                                         descending = abap_false
                                                                         is_grouped = abap_false ) ).

      o_salv_ida->default_layout( )->set_sort_order( it_sort_order = it_sort_order ).

* manuelle Sortierung für Spalte ausschalten
      o_salv_ida->field_catalog( )->disable_sort( iv_field_name = 'PASSNAME' ).

* Filter ausschalten
      o_salv_ida->field_catalog( )->disable_filter( iv_field_name = 'PASSNAME' ).

* nur bestimmte Spalten darstellen 1
      o_salv_ida->field_catalog( )->get_all_fields( IMPORTING ets_field_names = DATA(it_field_names) ).
      DELETE it_field_names WHERE table_line CP 'SEATS*'.

* nur bestimmte Spalten darstellen 2
*        DATA(it_field_names) = VALUE if_salv_gui_types_ida=>yts_field_name( ( CONV #( 'CARRID' ) )
*                                                                            ( CONV #( 'CONNID' ) )
*                                                                            ( CONV #( 'FLDATE' ) )
*                                                                            ( CONV #( 'FORCURKEY' ) )
*                                                                            ( CONV #( 'CUSTTYPE' ) )
*                                                                            ( CONV #( 'PASSNAME' ) ) ).

      o_salv_ida->field_catalog( )->set_available_fields( its_field_names = it_field_names ).

* passenden Beschreibungstext anhand der Domäne darstellen
      o_salv_ida->field_catalog( )->display_options( )->set_formatting( iv_field_name        = 'CUSTTYPE'
                                                                        iv_presentation_mode = if_salv_gui_types_ida=>cs_presentation_mode-description ).

* Textsuche im Gitter für Spalten 'CARRID' und 'PASSNAME' aktivieren (Button mit Lupe oben rechts)
      o_salv_ida->field_catalog( )->enable_text_search( 'CARRID' ).
      o_salv_ida->field_catalog( )->enable_text_search( 'PASSNAME' ).
      o_salv_ida->standard_functions( )->set_text_search_active( abap_true ).

* Layouts verwalten
      o_salv_ida->layout_persistence( )->set_persistence_options( is_persistence_key           = VALUE #( report_name = sy-repid )
                                                                  i_global_save_allowed        = abap_true
                                                                  i_user_specific_save_allowed = abap_true ).

      o_salv_ida->toolbar( )->enable_listbox_for_layouts( ).

* Titel
      o_salv_ida->display_options( )->set_title( 'Überschrift' ).

* Text für leere Tabelle
      o_salv_ida->display_options( )->set_empty_table_text( 'Keine Daten vorhanden.' ).

* Zebrastreifen
      o_salv_ida->display_options( )->enable_alternating_row_pattern( ).

* Datenbankfähigkeiten abfragen
      IF abap_true = cl_salv_gui_table_ida=>db_capabilities( )->is_text_search_supported( ).
* unscharfe Suche (Fuzzy) -> wird nur von HANA unterstützt
        o_salv_ida->text_search( )->set_field_similarity( '0.8' ).
        o_salv_ida->text_search( )->set_search_term( |Fehler| ).
      ENDIF.

* Wird eine Beschränkung der Anzahl der Datensätze empfohlen?
      IF cl_salv_gui_table_ida=>db_capabilities( )->is_max_rows_recommended( ).
* max. Anzahl der Datensätze beschränken
        o_salv_ida->set_maximum_number_of_rows( iv_number_of_rows = 500 ).
      ENDIF.

      o_salv_ida->fullscreen( )->display( ).

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

Links