SAP Knowledge Base Article - Public

2781808 - Database Returned The SQL Code 304 in Custom CDS Views or Custom Analytical Queries - S/4HANA Cloud

Symptom

The User is previewing a Custom Analytical Query but is getting the following error: 
"
The result set does not contain any relevant data. Database returned the SQL code 304. Error text: division by zero undefined: search table error: [6859] AttributeEngine: divide by zero;exception..." 

or 

When previewing a Custom CDS View the following error is raised:
"HTTP Request Failed. StatusCode: 400. Bad Request."

Environment

SAP S/4HANA Cloud Public Edition

Cause

This error is normally due to a calculated field in the data source of the query that is causing a divide by zero issue.

Resolution

  1. The user must edit the Custom CDS View in the Custom CDS Views app. 
  2. In the Selected Fields section check each of the calculated fields.
  3. If there is a division that is being done in any of the calculated fields then a check must be done first to ensure that the bottom will not equate to a 0.
  • Example of calculated field that is not correct
    <DataSource>.<FieldName> / <DataSource>.<FieldName2>
  • Example of a better way to do this calculation
    case
    when <DataSource>.<FieldName2> = 0
    then
    0
    else
    <DataSource>.<FieldName> / <DataSource>.<FieldName2>
    end

This is only an example, and should be thoroughly tested before use.

    Keywords

    divide by 0, multidimensional report, Calculated Field, Custom CDS Views, query, http request failed, calculation6859, AttributeEngine, Database returned the SQL code 304 , KBA , BC-SRV-APS-GKE , Generic CDS Key User Editor , BC-SRV-APS-EXT-AQD , Fiori based Query Designer , BW-RUI-FPM , FPM Analytical GUIBB , Problem

    Product

    SAP S/4HANA Cloud Public Edition all versions