我有一个简单的CDS视图。执行它时,出现错误invalid format (return table) row number 1 property name
。
我认为我需要将日期转换为字符串或char类型,但是存在此语法错误:
CHAR类型上的CAST DOGUM_TARIHI:目标类型的长度信息丢失
这是我的代码:
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
答案 0 :(得分:2)
为上帝的缘故,请添加以下长度信息:
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 起设置为 2019年8月22日。