ABAP 开发双击点击事件
REPORT zpp100.
TYPE-POOLS: slis.
TABLES:zscbb.
DATA:gt_scbb TYPE TABLE OF zscbb.
DATA:gw_scbb TYPE zscbb.
DATA: pgm LIKE sy-repid.
pgm = sy-repid.
DATA: fieldcat TYPE slis_t_fieldcat_alv,
fieldcat_ln LIKE LINE OF fieldcat,
sortcat TYPE slis_t_sortinfo_alv,
sortcat_ln LIKE LINE OF sortcat,
eventcat TYPE slis_t_event,
eventcat_ln LIKE LINE OF eventcat.
DATA: col_pos TYPE i.
PARAMETERS:
s_werks LIKE zscbb-werks OBLIGATORY.
**---------选择画面-------------------------
SELECT-OPTIONS:
"OBLIGATORY
s_matnr FOR zscbb-matnr.
TYPE-POOLS: slis.
DATA: gt_fieldcat TYPE slis_t_fieldcat_alv WITH HEADER LINE,
gs_layout TYPE slis_layout_alv,
-
gs_print TYPE slis_print_alv, "ALV打印格式 g_repid LIKE sy-repid.
DATA: v_stru_disvar TYPE disvariant, "ALV 显示格式
it_sort TYPE slis_t_sortinfo_alv WITH HEADER LINE, "ALV 排序内表
git_events TYPE slis_t_event, "ALV 事件
git_listheader TYPE slis_t_listheader. "ALV 表头
DATA l_title TYPE lvc_title.
*-----------------------内表声明---------------------------
INITIALIZATION.
AT SELECTION-SCREEN.
START-OF-SELECTION.
PERFORM frm_fetch_data.
"读取数据
- PERFORM frm_get_event. "设置自定义事件处理程序
PERFORM init_layout. "设置输出格式
PERFORM init_fieldcat. "设置输出字段
" PERFORM init_sort. "设置排序
PERFORM frm_output. - PERFORM FM_DOUBLE_CLICK USING E_ROW E_COLUMN ES_ROW_NO.
END-OF-SELECTION.
FORM frm_fetch_data.
SELECT
*
INTO CORRESPONDING FIELDS OF TABLE gt_scbb
FROM
mkal
WHERE
werks = s_werks AND
matnr IN s_matnr.
ENDFORM.
FORM init_layout .
gs_layout-zebra = ‘X’.
gs_layout-detail_popup = ‘X’.
gs_layout-colwidth_optimize = ‘X’.
- gs_layout-box_fieldname = ‘BOX’.
ENDFORM.
FORM init_fieldcat.
g_repid = sy-repid.
CLEAR gt_fieldcat[].
CALL FUNCTION ‘REUSE_ALV_FIELDCATALOG_MERGE’
EXPORTING
i_program_name = g_repid
i_structure_name = ‘ZSCBB’
CHANGING
ct_fieldcat = gt_fieldcat[]
EXCEPTIONS
inconsistent_interface = 1
program_error = 2
OTHERS = 3.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
LOOP AT gt_fieldcat.
CASE gt_fieldcat-fieldname.
WHEN ‘MATNR’.
gt_fieldcat-reptext_ddic = gt_fieldcat-seltext_l = gt_fieldcat-seltext_m = gt_fieldcat-seltext_s = ‘物料号’.
WHEN ‘WERKS’.
gt_fieldcat-reptext_ddic = gt_fieldcat-seltext_l = gt_fieldcat-seltext_m = gt_fieldcat-seltext_s = ‘工厂’.
WHEN ‘VERID’.
gt_fieldcat-reptext_ddic = gt_fieldcat-seltext_l = gt_fieldcat-seltext_m = gt_fieldcat-seltext_s = ‘生产版本’.
WHEN ‘BDATU’.
gt_fieldcat-reptext_ddic = gt_fieldcat-seltext_l = gt_fieldcat-seltext_m = gt_fieldcat-seltext_s = ‘有效至’.
WHEN ‘ADATU’.
gt_fieldcat-reptext_ddic = gt_fieldcat-seltext_l = gt_fieldcat-seltext_m = gt_fieldcat-seltext_s = ‘有效从’.
WHEN ‘STLAL’.
gt_fieldcat-reptext_ddic = gt_fieldcat-seltext_l = gt_fieldcat-seltext_m = gt_fieldcat-seltext_s = ‘可选的BOM’.
WHEN ‘STLAN’.
gt_fieldcat-reptext_ddic = gt_fieldcat-seltext_l = gt_fieldcat-seltext_m = gt_fieldcat-seltext_s = ‘BOM用途’.
WHEN ‘PLNNR’.
gt_fieldcat-reptext_ddic = gt_fieldcat-seltext_l = gt_fieldcat-seltext_m = gt_fieldcat-seltext_s = ‘组’.
WHEN ‘ALNAL’.
gt_fieldcat-reptext_ddic = gt_fieldcat-seltext_l = gt_fieldcat-seltext_m = gt_fieldcat-seltext_s = ‘组计数器’.
WHEN ‘TEXT1’.
gt_fieldcat-reptext_ddic = gt_fieldcat-seltext_l = gt_fieldcat-seltext_m = gt_fieldcat-seltext_s = ‘文本’.
ENDCASE.
MODIFY gt_fieldcat.
ENDLOOP.
ENDFORM.
FORM frm_output .
CONSTANTS cns_pf_status TYPE slis_formname VALUE ‘ALV_PF_STATUS’.
CONSTANTS cns_user_command TYPE slis_formname VALUE ‘ALV_USER_COMMAND’.
*ALV输出
g_repid = sy-repid.
CALL FUNCTION ‘REUSE_ALV_GRID_DISPLAY’
EXPORTING
i_callback_program = g_repid
-
i_callback_pf_status_set = 'CNS_PF_STATUS' i_callback_user_command = 'USER_COMMAND' is_layout = gs_layout it_fieldcat = gt_fieldcat[] i_save = 'A'
-
is_variant = v_stru_disvar
-
it_events = git_events[]
-
it_sort = it_sort[]
-
TABLESis_print = gs_print
t_outtab = gt_scbb
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 TYPE sy-ucomm
rs_selfield TYPE slis_selfield.
DATA lwa_filedcat LIKE LINE OF gt_fieldcat.
CASE r_ucomm.
WHEN ‘&IC1’. "此处通过设断点调试寻找r_ucomm值,填写到此处
CASE rs_selfield-fieldname.
WHEN ‘STLAL’.
READ TABLE gt_scbb INTO gw_scbb INDEX rs_selfield-tabindex.
SET PARAMETER ID ‘MAT’ FIELD gw_scbb-matnr.
SET PARAMETER ID 'WRK' FIELD gw_scbb-werks.
SET PARAMETER ID 'CSV' FIELD gw_scbb-stlan. "PARAMETER ID 为需要传入的参数ID F1下找
CALL TRANSACTION 'CS03' AND SKIP FIRST SCREEN .
WHEN 'PLNNR'.
READ TABLE gt_scbb INTO gw_scbb INDEX rs_selfield-tabindex.
SET PARAMETER ID 'MAT' FIELD gw_scbb-matnr.
SET PARAMETER ID 'WRK' FIELD gw_scbb-werks.
SET PARAMETER ID 'PLN' FIELD gw_scbb-PLNNR.
CALL TRANSACTION 'C203' AND SKIP FIRST SCREEN .
ENDCASE.
ENDCASE.
ENDFORM.