abap oo alv编辑时立刻调用事件如何实现

2024-11-28 03:52:25
推荐回答(1个)
回答1:

*----------------------------------------------------------------------*
* CLASS LCL_EVENT_HANDLER DEFINITION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS LCL_EVENT_HANDLER DEFINITION.
PUBLIC SECTION.
METHODS:
**--基于单元格的效验
HANDLE_DATA_CHANGED FOR EVENT DATA_CHANGED OF CL_GUI_ALV_GRID
IMPORTING ER_DATA_CHANGED E_ONF4 E_ONF4_BEFORE E_ONF4_AFTER E_UCOMM,
*--热点点击控制
HANDLE_HOTSPOT_CLICK FOR EVENT HOTSPOT_CLICK OF CL_GUI_ALV_GRID
IMPORTING E_ROW_ID E_COLUMN_ID ES_ROW_NO,

* 双击
HANDLE_DOUBLE_CLICK FOR EVENT DOUBLE_CLICK OF CL_GUI_ALV_GRID
IMPORTING E_ROW E_COLUMN ES_ROW_NO.

ENDCLASS. "LCL_EVENT_HANDLER DEFINITION

*----------------------------------------------------------------------*
* CLASS LCL_EVENT_HANDLER IMPLEMENTATION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS LCL_EVENT_HANDLER IMPLEMENTATION.
METHOD HANDLE_DATA_CHANGED. "单元格事件触发相关
PERFORM HANDLE_DATA_CHANGED USING ER_DATA_CHANGED.
ENDMETHOD. "HANDLE_DATA_CHANGED
*-- Handle hotspot click
METHOD HANDLE_HOTSPOT_CLICK. "单击事件
PERFORM HANDLE_HOTSPOT_CLICK USING E_ROW_ID E_COLUMN_ID ES_ROW_NO.
ENDMETHOD. "handle_hotspot_click
* 双击
METHOD HANDLE_DOUBLE_CLICK.
PERFORM HANDLE_DOUBLE_CLICK USING E_ROW E_COLUMN ES_ROW_NO.
ENDMETHOD. "handle_double_click
ENDCLASS. "LCL_EVENT_HANDLER IMPLEMENTATION

*&---------------------------------------------------------------------*
*& Form HANDLE_DATA_CHANGED
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->IR_DATA_CHANGED text
*----------------------------------------------------------------------*
FORM HANDLE_DATA_CHANGED USING IR_DATA_CHANGED
TYPE REF TO CL_ALV_CHANGED_DATA_PROTOCOL.
DATA LS_MOD_CELL TYPE LVC_S_MODI.
DATA LT_MOD_CELL TYPE LVC_T_MODI.
DATA LV_VALUE TYPE LVC_VALUE.

SORT IR_DATA_CHANGED->MT_MOD_CELLS BY ROW_ID.

ENDFORM. "HANDLE_DATA_CHANGED