OO面向对象ALV小测试
选择屏幕时,不需要话个alv控件,
这时也可以用OO ALV的
REPORT zlm_alv_oo_03.
DATA:
g_it_spfli TYPE TABLE OF spfli,
g_wa_spfli TYPE spfli.
DATA: l_ref_alv TYPE REF TO cl_gui_alv_grid.
DATA: g_s_events TYPE slis_t_event.
DATA: gt_events TYPE slis_t_event,
"ALV 事件
gw_events TYPE slis_alv_event.
DATA:
DATA:
DATA:
DATA:
*----------------------------------------------------------------------*
* 事件类定义
*----------------------------------------------------------------------*
CLASS lcl_event_handler DEFINITION .
PUBLIC SECTION .
METHODS:
*Toadd new functional buttons to the ALV toolbar
handle_toolbar FOR EVENT toolbar OF cl_gui_alv_grid
IMPORTING e_object ,"e_interactive ,
*Toimplement user commands
handle_user_command
FOR EVENT user_command OF cl_gui_alv_grid
IMPORTING e_ucomm ,
*Hotspotclick control
handle_hotspot_click
FOR EVENT hotspot_click OF cl_gui_alv_grid
IMPORTING e_row_id e_column_id es_row_no ,
*Double-clickcontrol
handle_double_click
FOR EVENT double_click OF cl_gui_alv_grid
IMPORTING e_row e_column ,
handle_data_changed
FOR EVENT data_changed OF cl_gui_alv_grid
IMPORTING er_data_changed .
ENDCLASS. "lcl_event_handler DEFINITION
*----------------------------------------------------------------------*
* CLASS lcl_event_handler IMPLEMENTATION
*----------------------------------------------------------------------*
* 事件类实现
*----------------------------------------------------------------------*
CLASS lcl_event_handler IMPLEMENTATION .
*HandleToolbar
METHOD handle_toolbar.
PERFORM handle_toolbar USING e_object ." e_interactive .
ENDMETHOD . "handle_toolbar
*HandleHotspot Click
METHOD handle_hotspot_click .
PERFORM handle_hotspot_click USING e_row_id e_column_id es_row_no .
ENDMETHOD . "handle_hotspot_click
*HandleDouble Click
METHOD handle_double_click .
PERFORM handle_double_click USING e_row e_column .
ENDMETHOD . "handle_double_click
*HandleUser Command
METHOD handle_user_command .
PERFORM handle_user_command USING e_ucomm .
ENDMETHOD. "handle_user_command
*HandleData Changed
METHOD handle_data_changed .
PERFORM handle_data_changed USING er_data_changed .
ENDMETHOD. "handle_data_changed
ENDCLASS . "lcl_event_handler IMPLEMENTATION
*&---------------------------------------------------------------------*
*& Form HANDLE_BEFORE_USER_COMMAND
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_E_UCOMM text
*----------------------------------------------------------------------*
FORM handle_before_user_command USING p_e_ucomm.
ENDFORM. " HANDLE_BEFORE_USER_COMMAND
*&---------------------------------------------------------------------*
*& Form HANDLE_DOUBLE_CLICK
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_E_ROW text
* -->P_E_COLUMN text
*----------------------------------------------------------------------*
FORM handle_double_click USING e_row TYPE lvc_s_row
e_column TYPE lvc_s_col.
READ TABLE g_it_spfli INTO g_wa_spfli INDEX e_row-index.
IF sy-subrc = 0 AND e_column-fieldname = 'CITYFROM'.
MESSAGE g_wa_spfli-cityfrom TYPE 'I'.
ELSE.
MESSAGE g_wa_spfli-carrid TYPE 'I'.
ENDIF.
ENDFORM.
*
*----------------------------------------------------------------------*
CLASS
*To
*To
*Hotspot
*Double-click
ENDCLASS.
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS
*Handle
*Handle
*Handle
*Handle
*Handle
ENDCLASS
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
FORM
ENDFORM.
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
*
*
*----------------------------------------------------------------------*
FORM
ENDFORM.