gpt4 book ai didi

abap - 在 ABAP CDS View 中将 DATS 转换为字符串

转载 作者:行者123 更新时间:2023-12-04 21:02:31 25 4
gpt4 key购买 nike

我有一个简单的 CDS View 。当我执行它时,出现错误 invalid format (return table) row number 1 property name .

我想我需要将日期转换为字符串或字符类型,但存在以下语法错误:

CAST DOGUM_TARIHI on type CHAR: Length information of target type is missing



这是我的代码:
define view ZUMBS_CDS008
as select from zumhr_ddl001 as hr {
personel_numarasi,
personel_adi,
cast(dogum_tarihi as abap.char) as te33 //<== error at this line
} group by personel_numarasi,personel_adi,dogum_tarihi

最佳答案

所以看在上帝的份上添加这个长度信息:

cast(dogum_tarihi as abap.char(8)) as te33 

但是,这只会按原样转换日期,而不会使其可读:
20190822 -> 20190822

如果你想根据格式 DD.MM.YYYY 使其可读,请像这样:
@AbapCatalog.sqlViewName: 'zcds_sql_usr02'
@EndUserText.label: 'test CDS view'
define view zcds_usr02 as select from usr02
{
usr02.bname,
usr02.gltgb,
cast(usr02.gltgb as abap.char(10)) as casted,
concat(
concat(substring( usr02.gltgb, 7, 2 ), '.'),
concat(substring( usr02.gltgb, 5, 2 ), concat('.', substring( usr02.gltgb, 1, 4 )))
) as readable
}
where usr02.gltgb <> '00000000';

这将来自 20190822 的日期22.08.2019 .

关于abap - 在 ABAP CDS View 中将 DATS 转换为字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57607023/

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