如何在SM30维护表时自动写入表字段的默认值-事件(EVENT)

在使用sm30维护表数据时,经常会要求一些字段是不可输入的,它们的值要自动带出来,也就是给一个默认值,比如一些描述字段,表数据的维护人,维护日期以及时间。这些是通过SE54中的“事件(EVENT)”来实现的。

下面以一个小例子详细说一下具体的实现过程。

1,首先要有一个表,咔嚓~~~下面这个表就创建好了,4个字段,包括2个描述字段-物料组描述和采购组描述,这两个字段就打算在表维护视图中做成不可输入,自动根据物料组和采购组读出来的。
在这里插入图片描述
2,SE54创建表维护视图

单击概述屏幕1,将屏幕中的两个描述字段修改为不可输入
在这里插入图片描述
在这里插入图片描述
将输入字段的勾去掉
在这里插入图片描述
3,SE54中进入事件屏幕,对表维护视图进行增强,
在这里插入图片描述
创建新条目,选择05事件,写入子例程名字也就是form名,然后点击编辑器按钮进入code editor

05事件就是在表维护视图保存的时候出发的事件,当然也可以通过其他事件来实现写入默认值功能,比如01-在数据库保存之前触发,21-填充隐藏字段(这个看名字可以实现此功能,但是没亲自测试过,05能实现就行,还要啥自行车)
在这里插入图片描述
把ABAP代码磊上,取出各自的描述,
在这里插入图片描述
结果就是下面这样,输入物料组之后点击保存按钮,物料组描述就会自动带出来。
在这里插入图片描述
附一个事件大全:
在这里插入图片描述
对应英语为:

List of Events available in Table maintenance
01 Before saving the data in the database
02 After saving the data in the database
03 Before deleting the data displayed
04 After deleting the data displayed
05 Creating a new entry
06 After completely performing the function ‘Get original’
07 Before correcting the contents of a selected field
08 After correcting the contents of a selected field
09 After getting the original of an entry
10 After creating the header entries for the change task (E071)
11 After changing a key entry for the change task (E071K)
12 After changing the key entries for the change task (E071K)
13 Exit editing (exit main function module)
14 After lock/unlock in the main function module
15 Before retrieving deleted entries
16 After retrieving deleted entries
17 Do not use. Before print: Event 26
18 After checking whether the data has changed
19 After initializing global variables, field symbols, etc.
20 after input in date sub screen (time-dep. tab. /views)
21 Fill hidden fields
22 Go to long text maintenance for other languages
23 Before calling address maintenance screen
24 After restricting an entry (time-dep. tab./views)
25 Individual authorization checks
26 Before creating a list
27 After creation or copying a GUID (not a key field)
28 After entering a date restriction for time-dep. views
AA Instead of the standard data read routine
AB Instead of the standard database change routine
AC Instead of the standard ‘Get original’ routine
AD Instead of the standard RO field read routine
AE Instead of standard positioning coding
AF Instead of reading texts in other languages
AG Instead of ‘Get original’ for texts in other languages
AH Instead of DB change for texts in other languages
ST GUI menu main program name
AI Internal use only

  • 1
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值