Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/sql-server/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
View ABAP CDS在时间戳字段上计数不同_View_Abap_Hana_Cds - Fatal编程技术网

View ABAP CDS在时间戳字段上计数不同

View ABAP CDS在时间戳字段上计数不同,view,abap,hana,cds,View,Abap,Hana,Cds,在时间戳字段上使用带有DISTINCT的COUNT时出现问题。下面是我的CD视图,请帮助。 我想把计数放在ConfirmedDate字段上 @AbapCatalog.sqlViewName: 'ZXEWMIWT' @AbapCatalog.compiler.compareFilter: true @AbapCatalog.preserveKey: true @AccessControl.authorizationCheck: #CHECK @EndUserText.label: 'In

在时间戳字段上使用带有DISTINCT的COUNT时出现问题。下面是我的CD视图,请帮助。 我想把计数放在ConfirmedDate字段上

 @AbapCatalog.sqlViewName: 'ZXEWMIWT'
 @AbapCatalog.compiler.compareFilter: true
 @AbapCatalog.preserveKey: true
 @AccessControl.authorizationCheck: #CHECK
 @EndUserText.label: 'Interface View for Warehouse Task detail'
 @OData.publish: true
// I* type:ddls

define view ZXEWMI_WT as select from /scwm/ordim_c as ORDIM_C {
    key ORDIM_C.lgnum as WarehouseNo,
    @UI.selectionField: [{ position: 1 }]
    @UI.lineItem: [{ position : 1 }]
    ORDIM_C.processor as Processor,
    @UI.lineItem: [{ position : 2 }]
    //count(distinct ORDIM_C.confirmed_at) as sum_wt

    **tstmp_to_dats( ORDIM_C.confirmed_at,
    abap_system_timezone( $session.client,'NULL' ),
    $session.client,
    'NULL' ) as ConfirmedDate**

}where processor <> '' 
group by lgnum, processor, confirmed_at;

看起来您在字段ORDIM_C.confirm_at中有毫秒级的准确时间戳,但您希望按天对结果进行分组

不幸的是,GroupBy只允许您按输入表/视图中的列进行分组。它不能用于计算列

但您可以做的是首先创建一个单独的CDS视图,该视图提供表/scwm/ordim_c的字段,并将时间戳转换为日期,然后查询该视图

视图1:

define view Z_ORDIM_C_WITH_DAY as 
select from /scwm/ordim_c as ORDIM_C {
    key ORDIM_C.lgnum as WarehouseNo,
    ORDIM_C.processor as Processor,
    tstmp_to_dats( ORDIM_C.confirmed_at,
    abap_system_timezone( $session.client,'NULL' ),
    $session.client,
    'NULL' ) as ConfirmedDate    
}
视图2:

define view ZXEWMI_WT as 
select from Z_ORDIM_C_WITH_DAY {
    key WarehouseNo,
    @UI.selectionField: [{ position: 1 }]
    @UI.lineItem: [{ position : 1 }]
    Processor,
    @UI.lineItem: [{ position : 2 }]
    count( * ) as sum_wt
    ConfirmedDate    
}
where processor <> ''
group by WarehouseNo, Processor, ConfirmedDate;

我有一个问题,你的问题是什么?在ConfirmedDate字段中,我需要将count与distinct放在一起,它不接受该表达式。。。这张CD是按用户显示每天的拾取次数…这里不需要区分,我身边没有EWM,但我假设confirmed_at是一个时间戳字段,因此在完全相同的秒/毫秒内不会有两个任务。请给出您的表行和预期输出,以及/scwm/ordim_c table definition>,这样在完全相同的秒/毫秒内就不会有两个任务了,您为什么这么认为?除非有主键或唯一约束,否则这是完全可能的。