SAP Knowledge Base Article - Public

2781808 - Database Returned The SQL Code 304 in Custom Analytical Queries

Symptom

  • Database returned the SQL code 304. Error text: division by zero undefined: search table error: [6859] exception 70006859: AttributeEngine: divide ..
  • zero;checkdigits(fixed(checkdigits(fixed(round("S APHANADB.#_SYS_QO_COL_7ce2cbc7ea50:401800001d29ca9 e.COL$6$", 000002), 13, 2), 15), 17, 2), 19) ->

Environment

SAP S/4HANA Cloud

Reproducing the Issue

This error can happen while previewing a custom analytical query

Cause

There is a calculated field that is causing a divide by zero issue

Resolution

  1. Edit the custom CDS view that the custom analytical query is based on 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 Design Studio Calculated Field Custom CDS Views , KBA , BC-SRV-APS-GKE , Generic CDS Key User Editor , BC-SRV-APS-EXT-AQD , Fiori based Query Designer , Problem

Product

SAP S/4HANA Cloud all versions