在ALV点击Key值调用TCode,跳过初始屏幕
在开发ALV报表时,通常业务部门会要求在ALV中点击单据号,屏幕跳转到具体业务凭证中查看业务明细,效果如下图:
点击销售销售订单号或者交货单号可传入单据号直接打开销售订单或交货单,实现方式如下:
一、查看初始屏幕参数名:
如查看销售订单初始屏幕,它的参数名为:AUN
二、在ABAP代码中调用:
form frm_alv_output . call function 'REUSE_ALV_GRID_DISPLAY' exporting i_callback_program = g_repid is_layout = wa_layout it_fieldcat = it_fieldcat i_save = 'X' i_callback_pf_status_set = 'SET_PF_STATUS' i_callback_user_command = 'USER_COMMAND' tables t_outtab = it_tab exceptions program_error = 1 others = 2. if sy-subrc <> 0. message id sy-msgid type sy-msgty number sy-msgno with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4. endif. endform. FORM user_command USING r_ucomm LIKE sy-ucomm rs_selfield TYPE slis_selfield. CASE r_ucomm. WHEN '&IC1'. IF rs_selfield-value IS INITIAL. r_ucomm = '&ETA'. ENDIF. CHECK rs_selfield-value IS NOT INITIAL. READ TABLE it_tab INTO wa_tab INDEX rs_selfield-tabindex. CASE rs_selfield-fieldname. WHEN 'VBELN'. "预制发票号 SET PARAMETER ID 'VF' FIELD rs_selfield-value. CALL TRANSACTION 'VF03' AND SKIP FIRST SCREEN. WHEN 'VGBEL'. "交货单号 SET PARAMETER ID 'VL' FIELD rs_selfield-value. CALL TRANSACTION 'VL03N' AND SKIP FIRST SCREEN. WHEN OTHERS. r_ucomm = '&ETA'. ENDCASE. ENDCASE. ENDFORM.