SAP Knowledge Base Article - Public

3166853 - A custom analytical query results in larger values than expected

Symptom

  • Values are seen in multiples when the query is executed.
  • Incorrect 'sum' values can be seen in the results of a custom analytical query.

Environment

  • Sales and Distribution (SD)
  • SAP S/4HANA Cloud All versions 

Cause

The issue is caused by the use of attributes from associations that have a “non-to-1” cardinality. When two tables such as, X and Y are joined and the cardinality between both is X 1->n Y, the entries of X will occur several (n) times.

For example; a single sales order item may have multiple business partners assigned. If sales item, item net value and business partner are all represented in a query, it would result in the sales item and net value data containing multiple entries - i.e. one for each different partner. In addition, if this query also includes a 'sum' field for calculating total net value of all items, the total net value would be an accumulation of all the net values represented in the query. Hence, the amount becomes exponentially larger.

Resolution

If the outcome is not desirable and data is misrepresented, please remove the fields from the query that contribute to duplication of data.

More information on cardinality can be found in the following online blog: https://blogs.sap.com/2018/08/20/cardinality-of-association-in-cds-view/

Keywords

ScheduleLine, netwr, VBAP, VBAK, salesdocumentItems, CDS Database View, Aggregation, AnalyticQuery, F1572, AnalyticQuery, SAP_CA_BC_ANA_AQD_PC , KBA , SD-ANA , Analytics , SD-SLS , Sales , How To

Product

SAP S/4HANA Cloud 2202