如何在cds视图中获取月份编号或名称

时间:2017-11-07 09:33:23

标签: abap hana-studio cds

我正在Hana工作室创建一个CDS视图,我希望在报告中从日期(YYYYMMDD)获取月份编号或名称,但我无法找到任何函数,如月份或其他任何内容,

请帮忙。

1 个答案:

答案 0 :(得分:2)

您可以加入包含所需信息的表t247:

@AbapCatalog.sqlViewName: 'ZDD_DATE_T'
@AccessControl.authorizationCheck: #NOT_REQUIRED
define view zdd_date_test
  with parameters p_date:abap.dats(8)
  as select from demo_expressions left outer join t247 as date_information on date_information.spras = $session.system_language {
  key mandt, 
  key id, 
  num1, 
  num2, 
  date_information.ltx as long_text
  } where date_information.mnr = substring(:p_date, 5, 2);

这将从表demo_expressions返回以下数据:

id,num1,num2,long_text
0,90,18,November
1,19,99,November
2,83,82,November
3,87,92,November
4,15,56,November
5,29,4,November
6,38,87,November
7,74,13,November
8,26,99,November
9,35,50,November

您使用substring(:p_date, 5, 2)来提取月份数,然后加入表t247