ABAP CDS on HANA-7

cds

Aggregate expression in CDS View

 

 

An aggregate expression calculates a single value from an operand operand by calling an aggregate function from multiple rows of a results set. They need Group By clause to aggregate values from multiple rows and  the non-aggregated fields  are specified in the GROUP BY clause.

Aggregate Functions:

0

Created a CDS view with below select with SUM function.

1


@AbapCatalog.sqlViewName: ‘ZFLIGHT_VW’
@AbapCatalog.compiler.compareFilter: true
@AccessControl.authorizationCheck: #CHECK
@EndUserText.label: ‘Flight View with Aggregation Operation’

define view Zflight_View
as select from sflight
{
key sflight.carrid,
key sflight.connid,
sum( price ) as Total_Amount,
sflight.currency
} group by carrid, connid, currency


Data Preview:

2

CDS view with SUM & COUNT functions

3


@AbapCatalog.sqlViewName: ‘ZFLIGHT_VW’
@AbapCatalog.compiler.compareFilter: true
@AccessControl.authorizationCheck: #CHECK
@EndUserText.label: ‘Flight View with Aggregation Operation’

define view Zflight_View
as select from sflight
{
key sflight.carrid,
key sflight.connid,
sum( price ) as Total_Amount,
sflight.currency,
count( *) as Lines
} group by carrid, connid, currency


Data Preview

4


SFLIGHT Table contents

5


 

2 comments

  1. Hello I’m trying to do something very similar, but I think there’s something about the new version that I’ve already changed, because it doesn’t add up.
    define view ZCDS_MM_invent_centro
    as select from mard
    {
    key werks,
    key lgort,
    sum( labst ) as labst_suma,
    count(*) as Lines
    }
    group by werks, lgort

    Like

Leave a Reply