SAP CDS HAVING CLAUSE V1



Get Example source ABAP code based on a different SAP table
  


• HAVING ABAP_CDS_SELECT_V1

ABAP_CDS_DDL - DDIC-Based View, SELECT, HAVING

ABAP_SYNTAX
... HAVING cds_cond ...

What does it do?
Defines a HAVING condition for the result set of a ABAP_CDS_V1_VIEW after a GROUP BY clause is evaluated. A HAVING condition can only be specified together with GROUP BY. For the operands, general and special rules apply when specifying the condition.
Removes all rows from the result set that do not meet the condition cds_cond specified after HAVING.



Latest notes:

Aggregate expressions can be specified in the HAVING condition, which is not possible in the WHERE condition.
NON_V5_HINTS
ABAP_HINT_END

ABAP_EXAMPLE_VX5
When accessed, the CDS view sales_order returns the number of business partners for each business partner role in which the total gross amount in euros is greater than 100000.00. @AbapCatalog.sqlViewName: 'SALES_ORDER_VW'
define view sales_order as
select from snwd_so
inner join
snwd_bpa on buyer_guid = snwd_bpa.node_key
{ key bp_role as role, //e.g. customer or supplier
count(distinct buyer_guid) as partners_count,
sum(snwd_so.gross_amount) as sum_gross_amount }
where snwd_so.currency_code = 'EUR'
group by bp_role
having sum(snwd_so.gross_amount) > 100000.00;
ABAP_EXAMPLE_END