ABAP程序中调用REUSE_ALV_GRID_DISPLAY_LVC显示ALV,经常会有双击某行或某字段跳转到其他tcode的需求。下面简单介绍一下。
双击事件的ucomm是’&IC1′.
完整代码:
REPORT ztest_alv_lvc_2click. TYPES:BEGIN OF gty_ekko, ebeln TYPE ekko-ebeln, verkf TYPE ekko-verkf, END OF gty_ekko. DATA:git_ekko TYPE STANDARD TABLE OF gty_ekko, gwa_ekko TYPE gty_ekko. DATA:git_fcat TYPE lvc_t_fcat, gwa_fcat LIKE LINE OF git_fcat, gwa_layout TYPE lvc_s_layo. CONSTANTS: gco_callback_user_command TYPE slis_formname VALUE 'FRM_USER_COMMAND'. START-OF-SELECTION. SELECT ebeln verkf INTO CORRESPONDING FIELDS OF TABLE git_ekko FROM ekko UP TO 10 ROWS. PERFORM frm_set_catalog. gwa_layout-zebra = 'X'. gwa_layout-sel_mode = 'A'. gwa_layout-cwidth_opt = 'X'. CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC' EXPORTING i_callback_program = sy-repid is_layout_lvc = gwa_layout it_fieldcat_lvc = git_fcat i_callback_user_command = gco_callback_user_command TABLES t_outtab = git_ekko[] EXCEPTIONS program_error = 1 OTHERS = 2. IF sy-subrc = 0. ENDIF. FORM frm_user_command USING i_ucomm TYPE sy-ucomm i_wa_selfield TYPE slis_selfield. CASE i_ucomm. WHEN '&IC1'. "Double click * if click on PO field, jump to me23n IF i_wa_selfield-fieldname = 'EBELN'. SET PARAMETER ID 'BES' FIELD i_wa_selfield-value. CALL TRANSACTION 'ME23N' AND SKIP FIRST SCREEN. ENDIF. WHEN OTHERS. ENDCASE. ENDFORM. *&---------------------------------------------------------------------* *& Form FRM_SET_CATALOG *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text * <-- p2 text *----------------------------------------------------------------------* FORM frm_set_catalog . DATA:l_pos TYPE i VALUE 1. CLEAR: l_pos. l_pos = l_pos + 1. gwa_fcat-coltext = 'PO'. gwa_fcat-scrtext_l = 'PO'. gwa_fcat-scrtext_m = 'PO'. gwa_fcat-scrtext_s = 'PO'. gwa_fcat-fieldname = 'EBELN'. gwa_fcat-col_pos = l_pos. gwa_fcat-outputlen = '10'. APPEND gwa_fcat TO git_fcat. l_pos = l_pos + 1. gwa_fcat-coltext = 'PO item'. gwa_fcat-scrtext_l = 'PO item'. gwa_fcat-scrtext_m = 'PO item'. gwa_fcat-scrtext_s = 'PO item'. gwa_fcat-fieldname = 'VERKF'. gwa_fcat-col_pos = l_pos. gwa_fcat-outputlen = '20'. APPEND gwa_fcat TO git_fcat. ENDFORM.
运行:
跳转到me23n显示采购订单3000000100
以上。
原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/19239.html