Drawer

Ein neues und bisher wenig beachtetes Control ist das „Schubladen-Control“ CL_GUI_CONTAINER_BAR, ein vertikales TabStrip-Modul für Controls. In diesem Beispiel werden die Reports aus bestimmten Bereichen gesucht und in „Schubladen angezeigt“. Das Original von www.sapnet.ru habe ich ein wenig schlanker und universeller gemacht.

In diesem Beispiel wird an den Selection-Screen ein Docking-Container angehängt, der das DrawerControl beinhaltet.

Es werden Programme aus bestimmten Bereichen angezeigt, die per Klick aufgerufen werden können.

Coding

REPORT ZZ_DRAWER.
* original http://www.sapnet.ru/viewtopic.php?t=1953
TABLES: trdir.
DATA: cc_drawer      TYPE REF TO cl_gui_docking_container,
      c_drawer       TYPE REF TO cl_gui_container_bar,
      c_container    TYPE REF TO cl_gui_container,
      l_caption      TYPE sbptcaptn,
      lt_captions    TYPE sbptcaptns,
      l_icon         TYPE swd_icon,
      lt_icons       TYPE swd_icons,
      ok_code        TYPE sy-ucomm,
      id             TYPE i,
      repid          TYPE sy-repid,
      dynnr          TYPE sy-dynnr.
* Display data
TYPES: BEGIN OF ty_data ,
         name LIKE trdir-name,
         cnam LIKE trdir-cnam,
         cdat LIKE trdir-cdat,
      END OF ty_data.
DATA : g_alv          TYPE REF TO cl_gui_alv_grid,
       g_alv_all      TYPE REF TO cl_gui_alv_grid,
       gs_data        TYPE ty_data,
       gt_data        TYPE STANDARD TABLE OF ty_data.

CLASS lcl_application DEFINITION DEFERRED.
CLASS cl_gui_cfw      DEFINITION LOAD.

DATA: c_application   TYPE REF TO lcl_application,
      c_alv           TYPE REF TO lcl_application.

PARAMETERS test.
*---------------------------------------------------------------------*
* CLASS lcl_application DEFINITION
*---------------------------------------------------------------------*
CLASS lcl_application DEFINITION.

  PUBLIC SECTION.
    METHODS:
       on_click FOR EVENT clicked OF cl_gui_container_bar
                IMPORTING
                  id
                  container,
                  on_hotspot_click FOR EVENT
                  hotspot_click OF cl_gui_alv_grid IMPORTING
                  e_row_id
                  e_column_id.

ENDCLASS. "lcl_application DEFINITION

*---------------------------------------------------------------------*
* CLASS lcl_application IMPLEMENTATION
*---------------------------------------------------------------------*
CLASS lcl_application IMPLEMENTATION.

  METHOD on_click.
    DATA: l_fcode TYPE ui_func,
    l_link TYPE swd_htmlco,
    l_quickinfo TYPE iconquick.
    DATA:
    lx_variant TYPE disvariant,
    lt_alv_cat TYPE lvc_t_fcat,
    lx_alv_cat TYPE lvc_s_fcat,
    lx_alv_lay TYPE lvc_s_layo.
    DEFINE m_fieldcat.
      add 1 to lx_alv_cat-col_pos.
      lx_alv_cat-fieldname = &1.
      case lx_alv_cat-fieldname.
        when 'NAME'.
          lx_alv_cat-key = 'X'.
          lx_alv_cat-hotspot = 'X'.
          lx_alv_cat-scrtext_m = 'Program Name'.
          lx_alv_cat-colddictxt = 'M'.
          lx_alv_cat-tipddictxt = 'M'.
        when 'CNAM'.
          lx_alv_cat-key = ''.
          lx_alv_cat-hotspot = ''.
          lx_alv_cat-scrtext_m = 'Created By'.
          lx_alv_cat-colddictxt = 'M'.
          lx_alv_cat-tipddictxt = 'M'.
        when 'CDAT'.
          lx_alv_cat-key = ''.
          lx_alv_cat-hotspot = ''.
          lx_alv_cat-scrtext_m = 'Created On'.
          lx_alv_cat-colddictxt = 'M'.
          lx_alv_cat-tipddictxt = 'M'.
      endcase.
      lx_alv_cat-ref_field = &2.
      lx_alv_cat-ref_table = &3.
      append lx_alv_cat to lt_alv_cat.
    END-OF-DEFINITION.

    DATA lv_cat TYPE c LENGTH 20.

    CASE id.
      WHEN 1.
        lv_cat = 'ZSD%'.
      WHEN 2.
        lv_cat = 'ZMM%'.
      WHEN 3.
        lv_cat = 'ZPP%'.
      WHEN 4.
        lv_cat = 'ZFI%'.
      WHEN 5.
        lv_cat = 'Z%'.
    ENDCASE.

    FREE : g_alv.
    IF g_alv IS INITIAL.
      CREATE OBJECT g_alv
        EXPORTING
          i_parent = container.
*Fill gt_data
      REFRESH gt_data[].
      SELECT name cnam cdat FROM trdir INTO CORRESPONDING FIELDS OF
      TABLE gt_data
      WHERE name LIKE lv_cat.
*Fill the field catalog
      REFRESH lt_alv_cat[].
      m_fieldcat 'NAME' 'NAME' 'TRDIR'.
      m_fieldcat 'CNAM' 'CNAM' 'TRDIR'.
      m_fieldcat 'CDAT' 'CDAT' 'TRDIR'.
*Layout
      CLEAR lx_alv_lay.
      lx_alv_lay-zebra = 'X'.
      lx_alv_lay-cwidth_opt = 'X'.
      lx_alv_lay-sel_mode = ' '.
      lx_alv_lay-no_toolbar = 'X'.
      lx_alv_lay-no_headers = 'X'.
      lx_variant-report = sy-cprog.
*Display
      CALL METHOD g_alv->set_table_for_first_display
        EXPORTING
          is_variant                    = lx_variant
          is_layout                     = lx_alv_lay
        CHANGING
          it_outtab                     = gt_data
          it_fieldcatalog               = lt_alv_cat
        EXCEPTIONS
          invalid_parameter_combination = 1
          program_error                 = 2
          too_many_lines                = 3
          OTHERS                        = 4.
      IF c_alv IS INITIAL.
        CREATE OBJECT c_alv.
      ENDIF.
      SET HANDLER c_alv->on_hotspot_click FOR g_alv.
      cl_gui_container=>set_focus( g_alv ).
    ENDIF.

  ENDMETHOD. "on_click

  METHOD on_hotspot_click.
    DATA:
    lx_selected_row TYPE lvc_s_row,
    ls_data TYPE ty_data.
    CLEAR lx_selected_row.
    MOVE-CORRESPONDING e_row_id TO lx_selected_row.
    READ TABLE gt_data INTO ls_data INDEX lx_selected_row-index.
    SET PARAMETER ID 'RID' FIELD ls_data-name.
    CALL TRANSACTION 'SE38' AND SKIP FIRST SCREEN.
  ENDMETHOD. "on_hotspot_click
ENDCLASS. "lcl_application IMPLEMENTATION


FORM init_drawer.

  repid = sy-repid.
  dynnr = sy-dynnr.
* create container for drawer
  IF cc_drawer IS INITIAL.
    CREATE OBJECT cc_drawer
      EXPORTING
        repid     = repid
        dynnr     = dynnr
        extension = 380.
  ENDIF.
* create drawer
  IF c_drawer IS INITIAL.
    l_caption-caption = 'Sales and Distribution Reports'(004). 
    l_caption-icon = icon_wizard.
    APPEND l_caption TO lt_captions.
    l_caption-caption = 'Material Management Reports'(005). 
    l_caption-icon = icon_date.
    APPEND l_caption TO lt_captions.
    l_caption-caption = 'Production Planning Reports'(006). 
    l_caption-icon = icon_display_text.
    APPEND l_caption TO lt_captions.
    l_caption-caption = 'Finance and Controlling Reports'(007). 
    l_caption-icon = icon_information.
    APPEND l_caption TO lt_captions.
    l_caption-caption = 'All custom Reports'(008).
    l_caption-icon = icon_refresh.
    APPEND l_caption TO lt_captions.

* Create cl_gui_container_bar
    CREATE OBJECT c_drawer
      EXPORTING
        parent                       = cc_drawer
        captions                     = lt_captions
      EXCEPTIONS
        max_number_of_cells_exceeded = 1
        OTHERS                       = 2.
    IF sy-subrc <> 0.
      SET SCREEN 0. LEAVE SCREEN.
    ENDIF.
* Create cl_gui_container_bar
    IF c_application IS INITIAL.
      CREATE OBJECT c_application.
    ENDIF.
    SET HANDLER c_application->on_click FOR c_drawer.
    c_drawer->set_active( 1 ).
  ENDIF.
ENDFORM.                    "init_drawer

INITIALIZATION.
  PERFORM init_drawer.
image_pdfimage_print
Enno Wulff
follow me
Letzte Artikel von Enno Wulff (Alle anzeigen)

Leave a Comment

Diese Website verwendet Akismet, um Spam zu reduzieren. Erfahre mehr darüber, wie deine Kommentardaten verarbeitet werden.