Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

[CDS View] - Aggregation amount/quantity and NONEX displayed

mve1
Newcomer
0 Likes
2,233

Hi,

I would like to create a CDS view that shows the amount ordered per order item and the amount delivered per item document but I'm having problems aggregating order and delivery amounts.

This view will be used in Analysis and BO.

In analysis, for the amount by item PO, it's show NONEX when not display by item PO. I add the annotation @DefaultAggregation:#SUM in my "CUBE" but the amount is multiply by the numbers of delivery (EKBE).

Below is an example to my code.

Do you have a solution to enable aggregation by order item and article document ?

Below is an example of what I need to do. I need to keep the EKPO and EKBE tables and need to keep the key EBELN, EBELP, BELNR, BUZEI and GJAHR.

First view : ZC_AAA

@AbapCatalog.sqlViewName: 'ZCAAA'
@VDM.viewType: #CONSUMPTION
@AbapCatalog.compiler.compareFilter: true
@AbapCatalog.preserveKey: true
@AccessControl.authorizationCheck: #CHECK
@EndUserText.label: 'Report AAA'
@Analytics.dataExtraction.enabled: true
@Analytics.query: true
@ObjectModel.usageType.sizeCategory: #XXL
@ObjectModel.usageType.serviceQuality: #D
@ObjectModel.usageType.dataClass: #MIXED

@OData.publish:true

define view ZC_AAA as select from ZI_AAA
{
key ZI_AAA.EBELN,
key ZI_AAA.EBELP,
key ZI_AAA.BELNR,
key ZI_AAA.BUZEI,
key ZI_AAA.GJAHR,
ZI_AAA.MENGE,
ZI_AAA.NETWR,
ZI_AAA.MENGE_DEL,
ZI_AAA.WRBTR

}

Second view : ZI_AAA

@AbapCatalog.sqlViewName: 'ZIAAA'
@AbapCatalog.compiler.compareFilter: true
@AbapCatalog.preserveKey: true
@AccessControl.authorizationCheck: #NOT_REQUIRED
@EndUserText.label: 'Report AAA'
@Analytics: { dataCategory: #CUBE }
@VDM.viewType: #COMPOSITE

define view ZI_AAA as select from ZI_BBB 
{
key ZI_AAA.EBELN,
key ZI_AAA.EBELP,
key ZI_AAA.BELNR,
key ZI_AAA.BUZEI,
key ZI_AAA.GJAHR,
@DefaultAggregation: #SUM
ZI_AAA.MENGE,
@DefaultAggregation: #SUM     // => Displayed NONEX if not @DefaultAggregation by item PO
ZI_AAA.NETWR<br>@DefaultAggregation: #SUM
ZI_AAA.MENGE_DEL,
@DefaultAggregation: #SUM
ZI_AAA.WRBTR
}

Third view : ZI_BBB

@AbapCatalog.sqlViewName: 'ZIBBB'
@AbapCatalog.compiler.compareFilter: true
@AbapCatalog.preserveKey: true
@AccessControl.authorizationCheck: #NOT_REQUIRED
@EndUserText.label: 'View CDS BBB'

define view ZI_BBB as select from ekko

inner join ekpo         on ekpo.ebeln = ekko.ebeln

left outer join ekbe    on ekbe.ebeln = ekpo.ebeln
                       and ekbe.ebelp = ekpo.ebelp
                       and ekbe.zekkn = 1     // only 1
                       and ekbe.vgabe = 1     // only 1 (delivery)
{
key EKPO.EBELN,
key EKPO.EBELP,
key EKBE.BELNR,
key EKBE.BUZEI,
key EKBE.GJAHR,
EKPO.MENGE,
EKPO.NETWR,
EKBE.MENGE as MENGE_DEL,
EKBE.WRBTR
}

Thank you !

0 REPLIES 0