本文的示例次要关注 Edm属性的 ABAP Datetime 解决逻辑。Datetime 只是在映射ABAP 类型和 EDM 类型时可能呈现不统一的例子之一。
对于 Edm.Datetime 属性,在后端,ABAP 字段能够示意为一个简略的日期或工夫戳,能够带有也能够不带有小数秒。
因而,在 Service Builder 中对于一个EDM.Datetime 类型的属性,须要额定的信息来将这个 EDM 类型映射到后端中正确的 ABAP 字段类型。如果没有正确地映射,就会导致谬误的类型赋值。
正确的类型赋值对于 MPC 的主动生成是至关重要的,因为 DPC 的实现是基于 MPC 类中生成的类型。
在 Service Builder 中实现这一指标的最后解决方案是:
- 如果 precision = 0 并且 scale = 0, 那么 ABAP internal type 为 type D.
- 如果 precision = 8 并且 scale = 0, 那么 ABAP internal type 为 type P,length 为 8 decimals 为 0 (
timestamp without fractional seconds
) - 如果 scale = 7, 那么 ABAP internal type 为 type P,length 11 decimals 7 (
timestamp with fractional seconds
)
除了应用下面示例中的 precision 和 scale 属性之外,也能够应用 Service Builder 中的ABAP Type Editor来间接设置
外部类型。在 ABAP 类型编辑器中,能够手动设置类别为外部类型,规定如下:
- Type Kind = Date, Length = 8, Decimals = 0 ( 代表 Simple Date, internal type 为 D)
- Type Kind = Packed, Length = 15, Decimals = 0 (timestamp without fractional seconds, internal type 在 MPC 中显示为 type P length 8 decimals 0)
- Type Kind = Packed, Length = 21, Decimals = 7 (timestamp with fractional seconds, internal type 在 MPC 中显示为 type P,length 11 decimals 7)
以上形容规定在上面的截图里失去体现:
或者,您能够应用ABAP类型编辑器将一个 Data Element
调配给一个属性。在 ABAP 类型编辑器中,能够手动将 Category
设置为 Date
,并在关联类型字段中输出数据元素名称。
当应用 RFC/BOR 导入或调配 DDIC 类型时,如果将构造调配给父构件(也就是 Entity Type 或简单类型),则不会在 property 级别进行调配。
当应用从 DDIC 构造导入选项时,日期字段按以下形式解决:
- 如果字段的域是 类型
TZNTSTMPS
,那么没有小数秒的工夫戳,MPC的外部类型是类型 P, 长度 8, 小数点 0 - 如果该字段的域类型为
TZNTSMPl
,则 MPC 外部类型为 P 类型,长度为 11 位,小数位为 7