Skip to Content
Technical Articles

Advanced Exception Aggregation with ABAP CDS View

Sometimes you need to use exception aggregation result in subsequent exception aggregation in order to archive desired result with ABAP CDS view. It is possible with multiple exception aggregation steps.

In my example, I need to:

  1. Get a count of distinct Sales Documents
  2. Get average of number by Sales Documents by Sales Organization

The above 2 exception aggregation steps are translated into following ABAP CDS exception aggregation annotation:

  @AnalyticsDetails.query.axis: #COLUMNS
  @EndUserText.label: 'Sales Document Avg by Sales Org'
  @AnalyticsDetails.query.decimals: 0    
  @AnalyticsDetails: {
    exceptionAggregationSteps: [
        { exceptionAggregationBehavior: #COUNT,
          exceptionAggregationElements: ['SalesDocument']  },
        { exceptionAggregationBehavior: #AVG,
          exceptionAggregationElements: ['SalesOrganization']  }                    
    ]
  }
  @AnalyticsDetails.query.formula: '1' 0 as SalesDocumentAvgBySalesOrg

Lets see it in action:

In first step number of distinct Sales Documents is calculated reducing context to just Sales Document, for example:

In second step number of Sales Documents is averaged out adding Sales Organization into context:

Complete ABAP CDS views source code can be downloaded from GitHub:

ZI_ExceptionAggregationCube

ZC_ExceptionAggregationQuery

 

 

 

10 Comments
You must be Logged on to comment or reply to a post.