业务场景
自建表在系统实施中的应用很广,通常分为配置表(C类型)和应用表(A类型)。对于配置表,由于数据量小,变更少,通过SAP的标准表维护SM30基本都能满足要求;对于应用表,一般数据量较大,用户的维护频率也较大,这时对于用户的一些附加要求,比如条件过滤、自动赋值等,往往超出SM30的标准功能,此时就需要做一些必要的扩展增强。
技术分析
当我们为自建表创建标准表维护时,要制定函数组和屏幕号,从而我们可以知道,SM30的表维护是调用用户指定的函数组屏幕来实现的。而这里的函数组是在用户的命名空间里,因此可以针对函数组做一些很灵活的扩展增强。
实例演示
开发物料描述维护界面维护自建表ZMM_MAT_DESC,具备选择屏幕筛选,维护时自动带出最后修改人和修改时间。后续可以通过自建表手动或后台更新到物料主数据中,在此不做演示。
2) 创建表维护
3) 针对上面创建的函数组ZMM_MAT_DESC,做以下增强处理
![](http://hi.csdn.net/attachment/201108/21/0_13139209986oOA.gif)
添加的Module 代码如下:
module mod_customize input.
"自动带出值
zmm_mat_desc-lname = sy-uname.
zmm_mat_desc-ldate = sy-datum.
zmm_mat_desc-ltime = sy-uzeit.
endmodule. " MOD_CUSTOMIZE INPUT
并修改100屏幕,把对应的三个字段设置为不可输入:
4) 创建程序,定义好选择界面,并通过标准函数:VIEW_MAINTENANCE_CALL 调用上面创建的SM30表维护
report zmm_mat_desc no standard page heading.
data: gs_zmm_mat_desc like zmm_mat_desc,
gt_zmm_mat_desc like table of gs_zmm_mat_desc,
gs_vimsellist like vimsellist,
gt_vimsellist like table of gs_vimsellist.
tables zmm_mat_desc.
select-options:
s_matnr for zmm_mat_desc-matnr,
s_maktx for zmm_mat_desc-maktx no intervals,
s_lname for zmm_mat_desc-lname no intervals,
s_ldate for zmm_mat_desc-ldate,
s_ltime for zmm_mat_desc-ltime.
select * into table gt_zmm_mat_desc
from zmm_mat_desc
where matnr in s_matnr
and maktx in s_maktx
and lname in s_lname
and ltime in s_ltime.
loop at gt_zmm_mat_desc into gs_zmm_mat_desc.
gs_vimsellist-viewfield = 'MATNR'.
gs_vimsellist-operator = 'EQ'.
gs_vimsellist-value = gs_zmm_mat_desc-matnr.
gs_vimsellist-and_or = 'OR'.
append gs_vimsellist to gt_vimsellist.
endloop.
call function 'VIEW_MAINTENANCE_CALL'
exporting
action = 'U'
view_name = 'ZMM_MAT_DESC'
tables
dba_sellist = gt_vimsellist
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
maintenance_prohibited = 14
others = 15.
if sy-subrc <> 0.
message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
endif
![](http://hi.csdn.net/attachment/201108/21/0_1313921013b1Fh.gif)
但是新增时报错:
这是因为指定了选择条件后,添加条目时还要去验证物料是否满足选择条件,显然不符合逻辑;
通过调试发现,需要在上面的Module里面清空掉选择条件限制的标识位,如下:
module mod_customize input.
"清空条件选择的标识位
clear x_header-selection.
"自动带出值
zmm_mat_desc-lname = sy-uname.
zmm_mat_desc-ldate = sy-datum.
zmm_mat_desc-ltime = sy-uzeit.
endmodule . " MOD_CUSTOMIZE INPUT