gpt4 book ai didi

abap - VALUE 从文字构造表行时出现语法错误

转载 作者:行者123 更新时间:2023-12-04 18:00:44 24 4
gpt4 key购买 nike

这是给你的。

这个怎么不编译

REPORT ZZY.

TYPES: my_int TYPE x LENGTH 4,
my_int_table TYPE STANDARD TABLE OF my_int WITH EMPTY KEY.

DATA(g_tab_my_int) = VALUE my_int_table( ( 2 ) ).

这个呢?
REPORT ZZY.

TYPES: my_int TYPE x LENGTH 4,
my_int_table TYPE STANDARD TABLE OF my_int WITH EMPTY KEY.

DATA(g_tab_my_int) = VALUE my_int_table( ( 2 * 1 ) ).

最佳答案

ABAP documentation内部 VALUE dtype|#( line | {LINES OF itab ...} )说:

If a data object is specified for line, this object must be compatible with the row type.

If an expression (built-in function, functional method, calculation expression, constructor expression, or table expression) is specified for line, the result of the expression must be convertible to the row type.



在你的例子中:
  • “2”是一个数字文字,因此是一个数据对象,只有当它与类型兼容时才有效,即它是完全相同的类型。
  • “1 * 2”是一个表达式,它是有效的,因为存在从类型 I 到类型 X 的转换规则。

  • 您可以输入更短的表达式,如“+ 2”: VALUE my_int_table( ( + 2 ) ).

    关于abap - VALUE 从文字构造表行时出现语法错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55501028/

    24 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com