ABAP-OOALV-回车事件:
首先要为ALV_GRID设置enter事件:
CALL METHOD GO_ALV_GRID->REGISTER_EDIT_EVENT
EXPORTING
I_EVENT_ID = CL_GUI_ALV_GRID=>MC_EVT_ENTER
EXCEPTIONS
ERROR = 1
OTHERS = 2.
然后编写事件接收器:
CLASS CL_EVENT_RECEIVER DEFINITION.
PUBLIC SECTION.
" ENTE时触发
METHODS HANDLE_ENTER
FOR EVENT DATA_CHANGED_FINISHED OF CL_GUI_ALV_GRID
IMPORTING E_MODIFIED ET_GOOD_CELLS.
PRIVATE SECTION.
ENDCLASS. "CL_EVENT_RECEIVER DEFINITION
CLASS CL_EVENT_RECEIVER IMPLEMENTATION.
" 实现ENTER 事件方法
METHOD HANDLE_ENTER.
DATA GS_LAYOUT_ALV TYPE LVC_S_LAYO.
DATA : LV_STABLE TYPE LVC_S_STBL.
PERFORM FOM_REFRESH .
LV_STABLE-ROW = '1'.
LV_STABLE-COL = '1'.
GS_LAYOUT_ALV-CWIDTH_OPT = 'X'.
CALL METHOD GO_ALV_GRID->SET_FRONTEND_LAYOUT
EXPORTING
IS_LAYOUT = GS_LAYOUT_ALV.
CALL METHOD GO_ALV_GRID->REFRESH_TABLE_DISPLAY
EXPORTING
IS_STABLE = LV_STABLE.
CALL METHOD CL_GUI_CONTROL=>SET_FOCUS
EXPORTING
CONTROL = GO_ALV_GRID.
CALL METHOD CL_GUI_CFW=>FLUSH.
ENDMETHOD. "HANDLE_MODIFY
ENDCLASS. "cl_event_receiver IMPLEMENTATION
最后去注册事件方法:
SET HANDLER LO_EVENT->HANDLE_ENTER FOR GO_ALV_GRID.