导语:在做功能性开发的时候,时常会有对应的配置表,配置表通过SM30,或者分配事务码给配置表进行维护,还是比较麻烦,下面说一下如何在选择屏幕直接进入配置表进行维护,文末有效果图。
前提:给数据库表通过表维护生成器创建一个可以用SM30使用的视图。
一、新增一个屏幕按钮
在选择屏幕定义好后,在后面增加语句,这里最多可以增加5个,这里用三个进行举例
TABLES : sscrfields.
*--SELECTION-SCREEN
SELECTION-SCREEN BEGIN OF BLOCK blc_001 WITH FRAME TITLE TEXT-001.
PARAMETERS : p_bukrs LIKE bseg-bukrs .
PARAMETERS : p_gjahr LIKE bseg-gjahr .
PARAMETERS : p_monat LIKE ztfi001-monat .
PARAMETERS : p_file LIKE rlgrap-filename MODIF ID r1.
SELECTION-SCREEN END OF BLOCK blc_001.
"增加按钮
SELECTION-SCREEN: FUNCTION KEY 1.
SELECTION-SCREEN: FUNCTION KEY 2.
SELECTION-SCREEN: FUNCTION KEY 3.
二、在INITIALIZATION事件下定义按钮图标及描述
INITIALIZATION.
PERFORM frm_sub_button. "模板按钮
*&---------------------------------------------------------------------*
*& Form frm_sub_button
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
*& --> p1 text
*& <-- p2 text
*&---------------------------------------------------------------------*
FORM frm_sub_button .
DATA:functxt TYPE smp_dyntxt.
CLEAR functxt.
functxt-icon_id = icon_export."icon_view_form
functxt-icon_text = '下载批导模板'.
sscrfields-functxt_01 = functxt.
CLEAR functxt.
functxt-icon_id = icon_table_settings."icon_view_form
functxt-icon_text = '维护【过账科目映射表】'.
sscrfields-functxt_02 = functxt.
CLEAR functxt.
functxt-icon_id = icon_table_settings."icon_view_form
functxt-icon_text = '维护【工资过账科目汇总维度配置表】'.
sscrfields-functxt_03 = functxt.
ENDFORM.
效果图
三、在AT SELECTION-SCREEN事件下实现按钮点击事件
AT SELECTION-SCREEN.
PERFORM frm_download_mod."选择屏幕按钮
*&---------------------------------------------------------------------*
*& Form frm_download_mod
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
*& --> p1 text
*& <-- p2 text
*&---------------------------------------------------------------------*
FORM frm_download_mod .
DATA:l_temp TYPE c,
l_str TYPE string.
CASE sscrfields-ucomm.
WHEN 'FC01'.
WHEN 'FC02'.
PERFORM frm_call_sm30 USING 'ZTFI013'.
WHEN 'FC03'.
PERFORM frm_call_sm30 USING 'ZTFI015'.
ENDCASE.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form frm_call_sm30
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
*& --> P_
*& --> WHEN
*& --> P_
*&---------------------------------------------------------------------*
FORM frm_call_sm30 USING p_name TYPE dd02v-tabname.
CALL FUNCTION 'VIEW_MAINTENANCE_CALL'
EXPORTING
action = 'U'
view_name = p_name
no_warning_for_clientindep = 'X'
EXCEPTIONS
client_reference = 1
foreign_lock = 2
invalid_action = 3
no_clientindependent_auth = 4
no_database_function = 5
no_editor_function = 6
no_show_auth = 7
no_tvdir_entry = 8
no_upd_auth = 9
only_show_allowed = 10
system_failure = 11
unknown_field_in_dba_sellist = 12
view_not_found = 13
OTHERS = 14.
ENDFORM.
四、效果演示
作者:小飞猪猪猪猪猪猪猪–CSDN