ALV面向对象方法研究:添加双击方法(二)

     继续上篇的内容。

     本文讲解如何添加双击的方法。

     首先程序的开头定义事件类,在ZALV_OO前:   

  CLASS LCL_EVENT_RECEIVER DEFINITION DEFERRED.

*定义事件
DATA EVENT_RECEIVER TYPE REF TO LCL_EVENT_RECEIVER.


* 定义事件属性跟方法
CLASS LCL_EVENT_RECEIVER DEFINITION.
PUBLIC SECTION.
METHODS:
* 双击方法
HANDLE_DOUBLE_CLICK
FOR EVENT DOUBLE_CLICK OF CL_GUI_ALV_GRID
IMPORTING E_ROW E_COLUMN.
ENDCLASS. "LCL_EVENT_RECEIVER DEFINITION

*----------------------------------------------------------------------*
* CLASS LCL_EVENT_RECEIVER IMPLEMENTATION
*----------------------------------------------------------------------*
* * 双击方法实现
*----------------------------------------------------------------------*
CLASS LCL_EVENT_RECEIVER IMPLEMENTATION.
METHOD HANDLE_DOUBLE_CLICK.
PERFORM GETRECORD USING E_ROW-INDEX E_COLUMN-FIELDNAME.
ENDMETHOD. "HANDLE_DOUBLE_CLICK
ENDCLASS. "LCL_EVENT_RECEIVER IMPLEMENTATION

*&---------------------------------------------------------------------*
*& Form GETRECORD
*&---------------------------------------------------------------------*
* 具体事件
*----------------------------------------------------------------------*
FORM GETRECORD USING E_ROW-INDEX E_COLUMN-FIELDNAME.
READ TABLE IT_SFLIGHT INDEX E_ROW-INDEX.
*将行列等信息合并到字符串
DATA: MSG(100).
CONCATENATE '行:' E_ROW-INDEX '列名:' E_COLUMN-FIELDNAME INTO MSG.
CONCATENATE S1 ' CONNID:' IT_SFLIGHT-CONNID INTO MSG.
CONCATENATE S1 ' CARRID:' IT_SFLIGHT-CARRID INTO MSG.
MESSAGE MSG TYPE 'I'.
ENDFORM. "GETRECORD

   然后在ZALV_OO里面刷新ALV前加上此事件:   

CREATE OBJECT EVENT_RECEIVER.
SET HANDLER EVENT_RECEIVER->HANDLE_DOUBLE_CLICK FOR GR_ALVGRID.

   如下图:

   

   

posted @ 2012-03-05 21:28  SAP梦心  阅读(1873)  评论(0编辑  收藏  举报
鄙视一切不懂技术又装懂的小人!