我试着用CAST写一条select语句,但我不知道如何放入float值。
这样做是行不通的。
SELECT
field1, field2,
CAST( field3 AS FLTP ) * CAST( '0.03' AS FLTP ) AS out2
FROM table1
INTO TABLE @DATA(lt_table1).
我得到这个错误信息: CASTs to a numeric type are not allowed for '0.03' (the type is incorrect)
所以我猜测引号中的任何内容都被认为是文本。
我找到了这个变通方法。
DATA: lv_discount TYPE f VALUE '0.03'.
SELECT
field1, field2,
CAST( field3 AS FLTP ) * CAST( @lv_flt AS FLTP ) AS out1
FROM table1
INTO TABLE @DATA(lt_table1).
没有这个变通方法我怎么做?
然而一个更好的选择是在Open SQL中使用ABAP表达式。
SELECT
field1, field2,
CAST( field3 AS FLTP ) * @( conv f( '0.03' ) ) AS out1
FROM table1
INTO TABLE @DATA(lt_table1).