1 定义命令处理Form
FORM USER_COMMAND USING R_UCOMM LIKE SY-UCOMM
RS_SELFIELD TYPE SLIS_SELFIELD.
DATA: VBELN1 LIKE L_SPETAB-VBELN, VBTYP1 LIKE L_SPETAB-VBTYP.
RS_SELFIELD-REFRESH = 'X'. "控制grid产生新屏幕
CASE R_UCOMM.
WHEN 'BEAN' OR '&IC1'. "双击事件
LOOP AT L_SPETAB WHERE SELK = 'X' .
VBELN1 = L_SPETAB-VBELN.
VBTYP1 = L_SPETAB-VBTYP.
CALL FUNCTION 'RV_CALL_CHANGE_TRANSACTION'
EXPORTING
VBELN = VBELN1
VBTYP = VBTYP1.
COL = COL_BEARBEITEN.
FARB-FARB2 = COL.
L_SPETAB-COL = FARB.
LF_LAYOUT-INFO_FIELDNAME = 'L_SPETAB-COL'.
MODIFY L_SPETAB.
CLEAR: VBELN1, VBTYP1.
ENDLOOP.
IF SY-SUBRC NE 0.
READ TABLE L_SPETAB INDEX RS_SELFIELD-TABINDEX.
IF SY-SUBRC = 0.
REPLACE '1-' WITH ' ' INTO RS_SELFIELD-SEL_TAB_FIELD.
CONDENSE RS_SELFIELD-SEL_TAB_FIELD NO-GAPS.
FELD = RS_SELFIELD-SEL_TAB_FIELD.
PERFORM SELECT USING RS_SELFIELD-TABINDEX.
CLEAR FELD.
ENDIF.
ENDIF.
RS_SELFIELD-COL_STABLE = 'X'.
RS_SELFIELD-ROW_STABLE = 'X'.
ENDCASE.
ENDFORM. "USER_COMMAND
2 定义一个常量包含"USER_COMMAND"
DATA: L_USER_COMMAND TYPE SLIS_FORMNAME VALUE 'USER_COMMAND'.
3 调用REUSE_ALV_GRID_DISPLAY
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
* I_BUFFER_ACTIVE = 'X'
* I_BACKGROUND_ID = 'ALV_BACKGROUND'
I_CALLBACK_PROGRAM = L_REPID
* I_CALLBACK_PF_STATUS_SET = L_STATUS
I_CALLBACK_USER_COMMAND = L_USER_COMMAND
* I_STRUCTURE_NAME = 'VBUK'
* IS_LAYOUT = LF_LAYOUT
IT_FIELDCAT = LF_FIELDCAT[]
* IT_EXCLUDING =
* IT_SPECIAL_GROUPS = LF_SP_GROUP
* I_DEFAULT = 'X'
* I_SAVE = L_SAVE
* IS_VARIANT = L_VARIANT
* IT_EVENTS = LF_EVENTS[]
* I_SCREEN_START_COLUMN = 0
* I_SCREEN_START_LINE = 0
* I_SCREEN_END_COLUMN = 0
* I_SCREEN_END_LINE = 0
* IMPORTING
* E_EXIT_CAUSED_BY_CALLER =
* ES_EXIT_CAUSED_BY_USER =
TABLES
T_OUTTAB = L_SPETAB .
相关连接:http://blog.csdn.net/CompassButton/archive/2006/09/08/1195672.aspx
再分享一下我老师大神的人工智能教程吧。零基础!通俗易懂!风趣幽默!还带黄段子!希望你也加入到我们人工智能的队伍中来!https://blog.csdn.net/jiangjunshow