ABAP UI---如何使用Vertical Tabstrip for Controls

1 建立一个新程序,代码如下:
 REPORT zdrawer.
TABLES: trdir.
INCLUDE <icon>.

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_sd TYPE REF TO cl_gui_alv_grid,
g_alv_mm TYPE REF TO cl_gui_alv_grid,
g_alv_pp TYPE REF TO cl_gui_alv_grid,
g_alv_fi 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.
*---------------------------------------------------------------------*
* 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.
    CASE id.
      WHEN 1.
        FREE : g_alv_sd.
        IF g_alv_sd IS INITIAL.
          CREATE OBJECT g_alv_sd
          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 'ZSD%'.
*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-grid_title = 'Sales and Distribution Reports'.
          lx_alv_lay-sel_mode = 'A'.
          lx_variant-report = sy-cprog.
*Display
          CALL METHOD g_alv_sd->set_table_for_first_display
          EXPORTING
* I_BUFFER_ACTIVE =
* I_BYPASSING_BUFFER =
* I_CONSISTENCY_CHECK =
* I_STRUCTURE_NAME =
          is_variant = lx_variant
* I_SAVE =
* I_DEFAULT = 'X'
          is_layout = lx_alv_lay
* IS_PRINT =
* IT_SPECIAL_GROUPS =
* IT_TOOLBAR_EXCLUDING =
* IT_HYPERLINK =
* IT_ALV_GRAPHICS =
* IT_EXCEPT_QINFO =
          CHANGING
          it_outtab = gt_data
          it_fieldcatalog = lt_alv_cat
* IT_SORT =
* IT_FILTER =
          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_sd.
        ENDIF.
      WHEN 2.
        FREE : g_alv_mm.
        IF g_alv_mm IS INITIAL.
          CREATE OBJECT g_alv_mm
          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 'ZMM%'.
*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-grid_title = 'Material Management Reports'.
          lx_alv_lay-sel_mode = 'A'.
          lx_variant-report = sy-cprog.
*Display
          CALL METHOD g_alv_mm->set_table_for_first_display
          EXPORTING
* I_BUFFER_ACTIVE =
* I_BYPASSING_BUFFER =
* I_CONSISTENCY_CHECK =
* I_STRUCTURE_NAME =
          is_variant = lx_variant
* I_SAVE =
* I_DEFAULT = 'X'
          is_layout = lx_alv_lay
* IS_PRINT =
* IT_SPECIAL_GROUPS =
* IT_TOOLBAR_EXCLUDING =
* IT_HYPERLINK =
* IT_ALV_GRAPHICS =
* IT_EXCEPT_QINFO =
          CHANGING
          it_outtab = gt_data
          it_fieldcatalog = lt_alv_cat
* IT_SORT =
* IT_FILTER =
          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_mm.
        ENDIF.
      WHEN 3.
        FREE : g_alv_pp.
        IF g_alv_pp IS INITIAL.
          CREATE OBJECT g_alv_pp
          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 'ZPP%'.
*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-grid_title = 'Production Planning Reports'.
          lx_alv_lay-sel_mode = 'A'.
          lx_variant-report = sy-cprog.
*Display
          CALL METHOD g_alv_pp->set_table_for_first_display
          EXPORTING
* I_BUFFER_ACTIVE =
* I_BYPASSING_BUFFER =
* I_CONSISTENCY_CHECK =
* I_STRUCTURE_NAME =
          is_variant = lx_variant
* I_SAVE =
* I_DEFAULT = 'X'
          is_layout = lx_alv_lay
* IS_PRINT =
* IT_SPECIAL_GROUPS =
* IT_TOOLBAR_EXCLUDING =
* IT_HYPERLINK =
* IT_ALV_GRAPHICS =
* IT_EXCEPT_QINFO =
          CHANGING
          it_outtab = gt_data
          it_fieldcatalog = lt_alv_cat
* IT_SORT =
* IT_FILTER =
          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_pp.
        ENDIF.
      WHEN 4.
        FREE : g_alv_fi.
        IF g_alv_fi IS INITIAL.
          CREATE OBJECT g_alv_fi
          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 'ZFI%'.
*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-grid_title = 'Finance and Controlling Reports'.
          lx_alv_lay-sel_mode = 'A'.
          lx_variant-report = sy-cprog.
*Display
          CALL METHOD g_alv_fi->set_table_for_first_display
          EXPORTING
* I_BUFFER_ACTIVE =
* I_BYPASSING_BUFFER =
* I_CONSISTENCY_CHECK =
* I_STRUCTURE_NAME =
          is_variant = lx_variant
* I_SAVE =
* I_DEFAULT = 'X'
          is_layout = lx_alv_lay
* IS_PRINT =
* IT_SPECIAL_GROUPS =
* IT_TOOLBAR_EXCLUDING =
* IT_HYPERLINK =
* IT_ALV_GRAPHICS =
* IT_EXCEPT_QINFO =
          CHANGING
          it_outtab = gt_data
          it_fieldcatalog = lt_alv_cat
* IT_SORT =
* IT_FILTER =
          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_fi.
        ENDIF.
      WHEN 5.
        FREE : g_alv_all.
        IF g_alv_all IS INITIAL.
          CREATE OBJECT g_alv_all
          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 'Z%'.
*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-grid_title = 'All custom Reports'.
          lx_alv_lay-sel_mode = 'A'.
          lx_variant-report = sy-cprog.
*Display
          CALL METHOD g_alv_all->set_table_for_first_display
          EXPORTING
* I_BUFFER_ACTIVE =
* I_BYPASSING_BUFFER =
* I_CONSISTENCY_CHECK =
* I_STRUCTURE_NAME =
          is_variant = lx_variant
* I_SAVE =
* I_DEFAULT = 'X'
          is_layout = lx_alv_lay
* IS_PRINT =
* IT_SPECIAL_GROUPS =
* IT_TOOLBAR_EXCLUDING =
* IT_HYPERLINK =
* IT_ALV_GRAPHICS =
* IT_EXCEPT_QINFO =
          CHANGING
          it_outtab = gt_data
          it_fieldcatalog = lt_alv_cat
* IT_SORT =
* IT_FILTER =
          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_all.
        ENDIF.
    ENDCASE.
  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
*DATA: c_application TYPE REF TO lcl_application.
START-OF-SELECTION.
  CALL SCREEN 100.
*&---------------------------------------------------------------------*
*& Module STATUS_0100 OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE status_0100 OUTPUT.
  SET PF-STATUS '100'.
  SET TITLEBAR '100'.
  repid = sy-repid.
  dynnr = sy-dynnr.
*Test the function
* create container for drawer
  IF cc_drawer IS INITIAL.
    CREATE OBJECT cc_drawer
    EXPORTING
    repid = repid
    dynnr = dynnr
    extension = 300.
  ENDIF.
* create drawer
  IF c_drawer IS INITIAL.
    l_caption-caption = 'Sales and Distribution Reports'(004)."text-004.
    l_caption-icon = icon_wizard.
    APPEND l_caption TO lt_captions.
    l_caption-caption = 'Material Management Reports'(005). "text-005.
    l_caption-icon = space.
    APPEND l_caption TO lt_captions.
    l_caption-caption = 'Production Planning Reports'(006). "text-006.
    l_caption-icon = icon_display_text.
    APPEND l_caption TO lt_captions.
    l_caption-caption = 'Finance and Controlling Reports'(007)."text-007.
    l_caption-icon = icon_display_text.
    APPEND l_caption TO lt_captions.
    l_caption-caption = 'All custom Reports'(008).          "text-008.
    l_caption-icon = icon_display_text.
    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.
    CALL METHOD c_drawer->set_active
      EXPORTING
        id = 1.
  ENDIF.
ENDMODULE. " STATUS_0100 OUTPUT
*&---------------------------------------------------------------------*
*& Module USER_COMMAND_0100 INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE user_command_0100 INPUT.
  IF ok_code = 'EX'.
    CALL METHOD c_drawer->free.
    CALL METHOD cc_drawer->free.
    SET SCREEN 0. LEAVE SCREEN.
  ELSEIF ok_code = 'HI'.
    CALL METHOD c_drawer->set_active
      EXPORTING
        id = id.
  ELSEIF ok_code = 'ENTE'.
    CALL METHOD c_drawer->set_active
      EXPORTING
        id = id.
  ENDIF.
ENDMODULE. " USER_COMMAND_0100 INPUT

2 新建SCreen 100
并在屏幕上建立三个空间
2.1  1个文本控件,输入显示文本"vertical_tab_control" 和控件任何名称
2.2  1个文本输入控件,控件名称为"ID"
2.3  1个按钮控件, 输入显示文本"Set tab" 和控件任何名称,功能码为"HI"
2.4  设置屏幕功能码返回字段为"OK_CODE"
2.5  设置screen module
PROCESS BEFORE OUTPUT.
 MODULE STATUS_0100.
*
PROCESS AFTER INPUT.
 MODULE USER_COMMAND_0100.
并保存激活

3 新建title 100
输入任何文本

4新建Status 100
 设置标准工具条按钮对应的功能码: "ENTE" 和"EX"

posted on 2007-05-22 16:25  毛小娃  阅读(159)  评论(0编辑  收藏  举报

导航