ABAP CDS Union ile ilgili kod.

Ön koşullar

1. ABAP CDS yaratma
2. SAP EPM

Senaryo

Satış siparişlerinin müşteri bazında toplam sipariş tutarlarını getiren ve müşterilerin derecelerini gösteren rapor.

ABAP CDS Kodu

@AbapCatalog.sqlViewName: 'ZZXB_V_UNION'
@AbapCatalog.compiler.compareFilter: true
@EndUserText.label: 'Union CDS örneği'
@AccessControl.authorizationCheck: #CHECK
define view zzxb_cdsv_union as 
    select from snwd_so as so
      inner join snwd_bpa as bpa
              on bpa.node_key = so.buyer_guid 
{
    key bpa.company_name,
    key so.currency_code,
    sum( so.net_amount ) as total_net_amount,
    '2. Derece' as customer_status    
}
group by bpa.company_name,
         so.currency_code
having sum( so.net_amount ) < 1000000

union

select from snwd_so as so
      inner join snwd_bpa as bpa
              on bpa.node_key = so.buyer_guid
{
    key bpa.company_name,
    key so.currency_code,
    sum( so.net_amount ) as total_net_amount,
    '1. Derece' as customer_status    
}
group by bpa.company_name,
         so.currency_code
having sum( so.net_amount ) >= 1000000