传统ALV事件.

在显示代码中一定要有下面参数:

       i_callback_user_command = 'USER_CALLBACK'

'USER_CALLBACK' 为处理事件的程序.

FORM. alv_display TABLES p_int_t.
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
      EXPORTING
        i_callback_program      = sy-repid
        is_layout               = g_layout_s
        it_fieldcat             = g_fieldcat_t[]
        i_callback_user_command = 'USER_CALLBACK'
        i_save                  = 'A'
      TABLES
        t_outtab                = p_int_t
      EXCEPTIONS
        program_error           = 1
        OTHERS                  = 2.
  ENDFORM.  " ALV_DISPLAY


 FORM. USER_CALLBACK USING r_ucomm LIKE sy-ucomm
                  rs_selfield TYPE slis_selfield.
    CASE r_ucomm.
      WHEN '&IC1'.        " SAP standard code for double-clicking
        DATA msg TYPE string.
        FIELD-SYMBOLS <line> LIKE LINE OF itab1.
         if rs_selfield-sel_tab_field = '1-VBELN'."当双击的是销售订单号列时,才触发
*1-VBELN测试rs_selfield-sel_tab_field的实际值
        READ TABLE itab1 INDEX rs_selfield-tabindex ASSIGNING <line>.
        IF sy-subrc = 0.
          SET PARAMETER ID: 'AUN' FIELD <line>-vbeln.
          CALL TRANSACTION 'VA03' AND SKIP FIRST SCREEN.
        ENDIF.
        endif.

       WHEN ' SPAN {font-family: "Courier New";font-size: 10pt;color: #000000;background: #FFFFFF;}ENTE '. "回车事件

 


    ENDCASE.
  ENDFORM.                    "user_command


你可能感兴趣的:(function,command,user,layout,SAP,callback)