最终效果图
代码:
REPORT ZTEST_HSS3.
INCLUDE ZTEST_HSS3_DATA.
INCLUDE ZTEST_HSS3_FRM.
INCLUDE ZTEST_HSS3_PBO.
INCLUDE ZTEST_HSS3_PAI.
INITIALIZATION.
*START-OF-SELECTION.
CREATE OBJECT G_APPLICATION.
CALL SCREEN 100.
ZTEST_HSS3_DATA的代码:
*&---------------------------------------------------------------------*
*& 包含 ZTEST_HSS3_DATA
*&---------------------------------------------------------------------*
TABLES:T001.
DATA: BEGIN OF GT_MARA OCCURS 0,
ICON LIKE ICON-ID, "状态指示灯
****超链接字段
LINK_NAME(20).
INCLUDE STRUCTURE MARA.
DATA: END OF GT_MARA.
DATA IT_T137 TYPE TABLE OF T137 WITH HEADER LINE.
DATA DYNNR TYPE SY-DYNNR VALUE '0200'.
DATA ALV_CONT TYPE REF TO CL_GUI_CUSTOM_CONTAINER.
*FIELD-SYMBOLS <FS_MARA> TYPE GT_MARA.
*DATA : GT_MARA LIKE TABLE OF MARA WITH HEADER LINE.
DATA: IT_MARA LIKE LINE OF GT_MARA.
DATA: G_DOCKING TYPE REF TO CL_GUI_DOCKING_CONTAINER,
G_SPLITTER TYPE REF TO CL_GUI_SPLITTER_CONTAINER,
G_CONTAINER TYPE REF TO CL_GUI_CONTAINER,
G_CONTAINER1 TYPE REF TO CL_GUI_CONTAINER,
G_GRID TYPE REF TO CL_GUI_ALV_GRID.
DATA: GT_FIELDCAT TYPE LVC_T_FCAT WITH HEADER LINE,
GS_LAYOUT TYPE LVC_S_LAYO.
DATA:TAB1 TYPE TABLE OF SVAL,
TAB LIKE LINE OF TAB1.
DATA: CODE TYPE C.
DATA LT_DDVAL TYPE LVC_T_DRAL WITH HEADER LINE.
DATA TT_FIELDCAT TYPE LVC_T_FCAT.
DATA WA_FIELDCAT LIKE LINE OF TT_FIELDCAT.
DATA L_POS TYPE I.
DATA: GT_SFLIGHT TYPE SFLIGHT OCCURS 0, "Output-Table
GT_FIELDCATALOG TYPE LVC_T_FCAT, "Fieldcatalog
GT_SORT TYPE LVC_T_SORT, "Sortiertabelle
OK_CODE LIKE SY-UCOMM. "OK-Code
CLASS CL_GUI_COLUMN_TREE DEFINITION LOAD.
CLASS CL_GUI_CFW DEFINITION LOAD.
DATA: LS_VARIANT TYPE DISVARIANT.
DATA TREE1 TYPE REF TO CL_GUI_ALV_TREE_SIMPLE.
DATA: LT_LIST_COMMENTARY TYPE SLIS_T_LISTHEADER,
L_LOGO TYPE SDYDO_VALUE.
INCLUDE <ICON>.
INCLUDE BCALV_SIMPLE_EVENT_RECEIVER.
"==========HTTP超链接
DATA: LS_HYPE TYPE LVC_S_HYPE,
LT_HYPE TYPE LVC_T_HYPE . "网址映射关系表,在具体链接到哪个网址就是根据 handle 中设定的值来获取的
CLASS EVENT_RECEIVER DEFINITION.
PUBLIC SECTION.
METHODS:
****热点
HANDLE_HOTSPOT 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 SENDER
E_ROW
E_COLUMN
ES_ROW_NO,
******工具栏
HANDLE_TOOLBAR FOR EVENT TOOLBAR OF CL_GUI_ALV_GRID IMPORTING E_OBJECT
E_INTERACTIVE,
****用户自定义命令
HANDLE_USER_COMMAND FOR EVENT USER_COMMAND OF CL_GUI_ALV_GRID IMPORTING E_UCOMM,
*****f4功能
ON_F4 FOR EVENT ONF4 OF CL_GUI_ALV_GRID IMPORTING E_FIELDNAME
E_FIELDVALUE
ES_ROW_NO
ER_EVENT_DATA
ET_BAD_CELLS
E_DISPLAY,
*****数据改变
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_MENU_BUTTON FOR EVENT MENU_BUTTON OF CL_GUI_ALV_GRID IMPORTING E_OBJECT
E_UCOMM.
ENDCLASS.
CLASS EVENT_RECEIVER IMPLEMENTATION.
METHOD HANDLE_HOTSPOT.
* MESSAGE S001(00) WITH '热点连接' DISPLAY LIKE 'S'.
****跳转到 物料详细信息
PERFORM FRM_MATNRINFO USING E_ROW_ID.
ENDMETHOD.
METHOD HANDLE_DOUBLE_CLICK.
IF E_COLUMN = 'BSTME'.
DATA VAL(30).
CALL METHOD SENDER->GET_CURRENT_CELL
IMPORTING
E_VALUE = VAL.
MESSAGE I001(00) WITH VAL.
ENDIF.
ENDMETHOD.
METHOD HANDLE_TOOLBAR.
PERFORM FRM_GETTOOLBAR USING E_OBJECT E_INTERACTIVE.
ENDMETHOD.
METHOD HANDLE_USER_COMMAND.
ENDMETHOD.
METHOD ON_F4.
* MESSAGE S001(00) WITH 'F4' DISPLAY LIKE 'S'.
SELECT MBRSH
BRARE
BBREF
FLREF
INTO CORRESPONDING FIELDS OF TABLE IT_T137
FROM T137.
CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
EXPORTING
* DDIC_STRUCTURE = ' '
RETFIELD = 'MBRSH'
* PVALKEY = ' '
DYNPPROG = SY-REPID "返回才程序
DYNPNR = SY-DYNNR "屏幕
DYNPROFIELD = 'MBRSH' "往页面回填值的地方
* STEPL = 0
* WINDOW_TITLE =
* VALUE = ' '
VALUE_ORG = 'S'
* MULTIPLE_CHOICE = ' '
* DISPLAY = ' '
* CALLBACK_PROGRAM = ' '
* CALLBACK_FORM = ' '
* CALLBACK_METHOD =
* MARK_TAB =
* IMPORTING
* USER_RESET =
TABLES
VALUE_TAB = IT_T137[]
* FIELD_TAB =
* RETURN_TAB =
* DYNPFLD_MAPPING =
* EXCEPTIONS
* PARAMETER_ERROR = 1
* NO_VALUES_FOUND = 2
* OTHERS = 3
.
IF SY-SUBRC <> 0.
* Implement suitable error handling here
ENDIF.
ENDMETHOD.
METHOD HANDLE_DATA_CHANGED.
ENDMETHOD.
METHOD HANDLE_MENU_BUT