SAP Knowledge Base Article - Public

3658772 - Custom Analytical Query failing to preview data due to SQL code 339 - SAP S/4HANA Cloud Public Edition

Symptom

When trying to preview data from a custom analytical query it is throwing error message "Database returned the SQL code 339" & "Cannot convert string to int".

Environment

SAP S/4HANA Cloud Public Edition

Reproducing the Issue

  1. Open the application 'Custom Analytical Queries'.
  2. Search for the custom query and attempt to preview the data.
  3. The error message "Database returned the SQL code 339" occurs.

Cause

A value in the dataset was read as a string when the expected value is integer.

Resolution

  1. Check the calculations and measures defined within the Custom CDS View that is being consumed by the analytical query.
  2. Identify and correct any values recorded as strings where integers are expected. For example:
    • Replace '1.' with '1' or '1.0' to ensure proper data type conversion.

Keywords

custom analytical query, sql code 339, conversion, error, string, integer, empty dataset, custom cds view, business catalog, sql, query, s/4hana, measures, calculations, 339 , KBA , BC-SRV-APS-EXT-AQD , Fiori based Query Designer , Problem

Product

SAP S/4HANA Cloud Public Edition all versions