3、在上面caller_exit定义的FORM.:'FM_BUTTON'里通过函数‘GET_GLOBALS_FROM_SLVC_FULLSCR’得到ALV的GRID对象,再设置这个GRID的BUTTON_CLICK事件。
DATAGV_GRIDTYPEREFTOCL_GUI_ALV_GRID.
FORMFM_BUTTONUSINGE_GRIDTYPESLIS_DATA_CALLER_EXIT.
CALLFUNCTION'GET_GLOBALS_FROM_SLVC_FULLSCR'
*EXPORTING
*IR_SALV_FULLSCREEN_ADAPTER=
IMPORTING
*ET_EXCLUDING=
*E_REPID=
*E_CALLBACK_PROGRAM=
*E_CALLBACK_ROUTINE=
E_GRID=GV_GRID
*ET_FIELDCAT_LVC=
*ER_TRACE=
*E_FLG_NO_HTML=
*ES_LAYOUT_KKBLO=
*ES_SEL_HIDE=
*ET_EVENT_EXIT=
*ER_FORM_TOL=
*ER_FORM_EOL=
.
CREATEOBJECTGV_EVENT_RECEIVER.
SETHANDLERGV_EVENT_RECEIVER->HANDLE_BUTTON_CLICKFORGV_GRID.
ENDFORM.
4、在CLASS中定义的BUTTON_CLICK事件的FORM:BUTTON_CLICK中写需要单击按钮后完成的处理。
FORMBUTTON_CLICKUSINGP_COL_ID
P_ROW_NOTYPElvc_s_roid.
READTABLEITAB_ALVDATAINTOWA_ALVDATAINDEXP_ROW_NO-ROW_ID.
PERFORMFM_DISPLAY_COMMENT.
ENDFORM.
5、DISPLAYALV
PERFORMFM_EVENT_BUILD.
*CallALVFuncation
CALLFUNCTION'REUSE_ALV_GRID_DISPLAY_LVC'
EXPORTING
I_CALLBACK_PROGRAM=SY-REPID
I_GRID_TITLE=GV_TITLE
I_DEFAULT='X'
I_SAVE='A'
IT_EVENTS=GV_EVENTS
IT_FIELDCAT_LVC=GV_FIELDCAT_ALV[]
IS_LAYOUT_LVC=GV_LAYOUT
I_CALLBACK_PF_STATUS_SET=GV_STATUS
I_CALLBACK_USER_COMMAND='USER_COMMAND'
TABLES
T_OUTTAB=ITAB_ALVDATA
EXCEPTIONS
PROGRAM_ERROR=1
OTHERS=2.