用户经常会有这样的需求,在ALV显示时双击某一字段值,自动定位到了某个T-CODE,把该字段值填入,并把第一个界面忽略掉.
代码:
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'
EXPORTING
* I_INTERFACE_CHECK = ' '
* I_BYPASSING_BUFFER =
* I_BUFFER_ACTIVE =
I_CALLBACK_PROGRAM = L_REPID
I_CALLBACK_USER_COMMAND = 'SUB_USER_COMMAND'
* i_callback_pf_status_set = 'SUB_SET_PF_STATUS'
* I_CALLBACK_TOP_OF_PAGE = ' '
* I_CALLBACK_HTML_TOP_OF_PAGE = ' '
* I_CALLBACK_HTML_END_OF_LIST = ' '
* I_STRUCTURE_NAME =
* I_BACKGROUND_ID = ' '
* i_grid_title =
* I_GRID_SETTINGS =
IS_LAYOUT_LVC = L_LAYOUT
IT_FIELDCAT_LVC = G_ITAB_FIELDCAT_LVC
* IT_EXCLUDING =
* IT_SPECIAL_GROUPS_LVC =
IT_SORT_LVC = G_ITAB_SORT_LVC
* IT_FILTER_LVC =
* IT_HYPERLINK =
* IS_SEL_HIDE =
* I_DEFAULT = 'X'
* I_SAVE = ' '
* IS_VARIANT =
* IT_EVENTS =
* IT_EVENT_EXIT =
* IS_PRINT_LVC =
* IS_REPREP_ID_LVC =
* I_SCREEN_START_COLUMN = 0
* I_SCREEN_START_LINE = 0
* I_SCREEN_END_COLUMN = 0
* I_SCREEN_END_LINE = 0
* I_HTML_HEIGHT_TOP =
* I_HTML_HEIGHT_END =
* IT_EXCEPT_QINFO_LVC =
* IR_SALV_FULLSCREEN_ADAPTER =
* IMPORTING
* E_EXIT_CAUSED_BY_CALLER =
* ES_EXIT_CAUSED_BY_USER =
TABLES
T_OUTTAB = G_T_RESULT
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2.
用到其中的参数:
I_CALLBACK_USER_COMMAND = 'SUB_USER_COMMAND'
创建一个FORM:
FORM SUB_USER_COMMAND USING R_UCOMM LIKE SY-UCOMM
RS_SELFIELD TYPE SLIS_SELFIELD.
DATA: L_RESULT LIKE LINE OF G_T_RESULT.
IF R_UCOMM = '&IC1'. "双击
READ TABLE G_T_RESULT INDEX RS_SELFIELD-TABINDEX INTO L_RESULT. "双击所在行
IF SY-SUBRC = 0.
CASE RS_SELFIELD-SEL_TAB_FIELD.
WHEN '1-VBELN'.
SET PARAMETER ID 'VF' FIELD L_RESULT-VBELN.
CALL TRANSACTION 'VF03' AND SKIP FIRST SCREEN.
WHEN '1-MBLNR'.
SET PARAMETER ID 'MBN' FIELD L_RESULT-MBLNR.
CALL TRANSACTION 'MB03' AND SKIP FIRST SCREEN.
ENDCASE.
ENDIF.
ENDIF.
ENDFORM. "SUB_USER_COMMAND
大功告成,其中WHEN 值在不同的系统中显示值不同,需要调试再定.
[@more@]来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/13557695/viewspace-1001400/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/13557695/viewspace-1001400/