abap alv双击事件

TABLES:MARA.
TYPE-POOLS: SLIS.
SELECT-OPTIONS:MATNR FOR MARA-MATNR OBLIGATORY.

DATA:LT_MARA TYPE TABLE OF MARA WITH HEADER LINE,
FIELDCAT TYPE SLIS_T_FIELDCAT_ALV WITH HEADER LINE,
LAYOUT TYPE SLIS_LAYOUT_ALV,
W_REPID LIKE SY-REPID.

START-OF-SELECTION.
SELECT * FROM MARA INTO TABLE LT_MARA
WHERE MATNR IN MATNR.

W_REPID = SY-REPID.

  • 定义热键显示字段,使双击事件有效
    FIELDCAT-REF_TABNAME = ‘LT_MARA’.
    FIELDCAT-FIELDNAME = ‘MATNR’.
    FIELDCAT-HOTSPOT = ‘X’.
    APPEND FIELDCAT.

CALL FUNCTION ‘REUSE_ALV_GRID_DISPLAY’
EXPORTING
I_CALLBACK_PROGRAM = W_REPID "定义回执程序
IS_LAYOUT = LAYOUT
I_STRUCTURE_NAME = ‘MARA’
I_CALLBACK_USER_COMMAND = ‘ALV_USER_COMMAND’ "定义执行事件
IT_FIELDCAT = FIELDCAT[]
TABLES
T_OUTTAB = LT_MARA.

---------------------------------------------------------------------

  •   事件触发子程序                         *
    

---------------------------------------------------------------------
FORM ALV_USER_COMMAND USING R_UCOMM LIKE SY-UCOMM
RS_SELFIELD TYPE SLIS_SELFIELD.
CASE R_UCOMM.
WHEN ‘&IC1’.

  • 获取当前ALV所在行数据
    READ TABLE LT_MARA INDEX RS_SELFIELD-TABINDEX.
    SET PARAMETER ID: ‘MAT’ FIELD LT_MARA-MATNR.
    CALL TRANSACTION ‘MM03’ AND SKIP FIRST SCREEN.
    ENDCASE.
    ENDFORM.

作者:兔宝
来源:CSDN
原文:https://blog.csdn.net/szlaptop/article/details/8252093
版权声明:本文为博主原创文章,转载请附上博文链接!

上一篇:ALV 颜色设置(行,列,单元格)


下一篇:WPF Step By Step2 -基础知识介绍