如何在 abap 中限制表中的值

How to restrict values in a ztable in abap

我的 ztable 中有一个字段,可以按小时计算用户的出席情况。该值应介于 0.00 和 42.00

之间

现在我在Value Range选项卡下的域中找到了三个点:

  1. 单值: 我不想输入所有 4200 个可能的条目。
  2. Intervals:我没有成功使用这些来限制值。它在输入时显示了一些对话框,但我仍然能够输入 45.00
  3. 值Table:同1,我不想输入所有4200个可能的条目。

那我该怎么做呢?

F1 帮助回答了我为什么它不起作用的问题:

Lower limit of interval

The value range of a domain can be limited by defining fixed values. In this case, only the values entered in the fixed values are possible for all the table fields referring to this domain. The fixed values can be single values or intervals.

You can only define fixed values for domains of data types CHAR, NUMC, DEC, INT1, INT2 and INT4.

Dependencies

There is only an input check of the mask for data types CHAR and NUMC. Note that the system only checks single values for NUMC.

if a check table and fixed values are defined for a table field, only values that exist in both the check table and in the fixed values can be entered in the field

正如您所发现的,您无法在数据字典级别执行此操作。因此,您必须在应用程序级别执行此操作。

如果不需要向用户发送关于值越界的消息,您可以通过创建将越界条目更改为 0.00 或 42.00 的转换出口,为使用特定域的每个字段自动执行此操作。但是,这可能会让用户感到困惑,因为当他们输入 43.00 时,该值会在没有任何警告的情况下更改为 42.00。