ABAP顾问
分类:
2008-10-29 10:07:03
*&---------------------------------------------------------------------*
*& Report Z_BARRY_ALV_GRID_EVENT
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT z_barry_alv_grid_event.
DATA: itab TYPE TABLE OF sflight .
DATA: ok_code LIKE sy-ucomm .
DATA: go_grid TYPE REF TO cl_gui_alv_grid,
go_custom_container TYPE REF TO cl_gui_custom_container.
CLASS lcl_event_receiver DEFINITION DEFERRED .
DATA: event_receiver TYPE REF TO lcl_event_receiver.
*---------------------------------------------------------------------*
* CLASS lcl_event_receiver DEFINITION
*---------------------------------------------------------------------*
CLASS lcl_event_receiver DEFINITION.
PUBLIC SECTION.
METHODS catch_doubleclick
FOR EVENT double_click OF cl_gui_alv_grid
IMPORTING e_row
e_column
es_row_no .
ENDCLASS. "lcl_event_receiver DEFINITION
*---------------------------------------------------------------------*
* CLASS lcl_event_receiver IMPLEMENTATION
*---------------------------------------------------------------------*
CLASS lcl_event_receiver IMPLEMENTATION.
METHOD catch_doubleclick.
CALL METHOD cl_gui_cfw=>set_new_ok_code
EXPORTING
new_code = 'BACK'.
CALL METHOD cl_gui_cfw=>flush.
ENDMETHOD. "catch_doubleclick
ENDCLASS. "lcl_event_receiver IMPLEMENTATION
START-OF-SELECTION.
CALL SCREEN 0100 .
*&---------------------------------------------------------------------*
*& Module STATUS_0100 OUTPUT
*&---------------------------------------------------------------------*
MODULE status_0100 OUTPUT.
SET PF-STATUS 'MAIN100'.
IF go_grid IS INITIAL.
CREATE OBJECT go_grid
EXPORTING
i_parent = cl_gui_container=>screen0.
CREATE OBJECT event_receiver.
SET HANDLER event_receiver->catch_doubleclick FOR go_grid.
SELECT * FROM sflight INTO TABLE itab UP TO 10 ROWS.
CALL METHOD go_grid->set_table_for_first_display
EXPORTING
i_structure_name = 'SFLIGHT'
CHANGING
it_outtab = itab.
ENDIF.
ENDMODULE. " STATUS_0100 OUTPUT
*&---------------------------------------------------------------------*
*& Module USER_COMMAND_0100 INPUT
*&---------------------------------------------------------------------*
MODULE user_command_0100 INPUT.
CASE ok_code.
WHEN 'BACK'.
LEAVE PROGRAM.
ENDCASE.
CLEAR ok_code .
ENDMODULE. " USER_COMMAND_0100 INPUT
另注:CL_GUI_ALV_GRID的SET_REGISTERED_EVENTS方法系统没有实现,不让使用
chinaunix网友2009-04-04 23:00:31
有点明白了。等清明节假期后,再看下REUSE_ALV_GIRD_DISPLAY的代码。我是会计系的,程序方面比较笨,以后还请白老师多指点啊~
chinaunix网友2009-04-01 15:22:48
试了一下: 首先,在OO ALV里添加了一个自定义按钮,譬如SHOW,用于改变ALV的编辑状态。 然后,我在屏幕PAI的USER_COMMAND中调用ALV_GRID的set_function_code方法,把功能码SHOW传过去,不起任何作用。请教下啊,自带按钮是指的什么按钮呢?不好意思啊,ABAP初学~