Error
Error Code:
1310
SAP S/4HANA Error 1310: Invalid Scalar Type Usage
Description
This error indicates that a scalar data type has been used in an SAP S/4HANA SQLScript context where it is explicitly not allowed or expected. It typically occurs during the execution or compilation of custom ABAP CDS views, SQLScript procedures, or functions within the SAP HANA database layer, particularly when defining return types or parameters.
Error Message
ERR_SQLSCRIPT_NOT_ALLOWED_SCALAR_TYPE: Scalar type is not allowed
Known Causes
4 known causesIncorrect Function Return Type
A SQLScript function or procedure has been defined to return a scalar type, but the calling context expects a table type or a more complex structure.
Scalar Variable in Table Context
An attempt was made to assign a scalar value or variable to a table type variable or a field within a table context where only a table type is permitted.
Invalid Parameter Declaration
A parameter in a SQLScript procedure or function is declared as a scalar type, but the consuming logic or the database expects a different, non-scalar type.
Misuse in Table Type Definition
Within the definition of a custom table type, a scalar type was incorrectly used in a way that conflicts with the expected structured format of the table type.
Solutions
3 solutions available1. Identify and Correct Invalid Scalar Type in SQL Script medium
Pinpoint the exact scalar type causing the error and replace it with an allowed type.
1
Analyze the SQL script that is triggering Error 1310. Look for scalar type declarations within the script.
ERR_SQLSCRIPT_NOT_ALLOWED_SCALAR_TYPE: Scalar type is not allowed
2
Identify which scalar type is marked as 'not allowed'. Common culprits include custom or deprecated types that are not directly supported in S/4HANA SQL scripting.
Example: DECLARE my_variable SOME_CUSTOM_TYPE;
3
Consult SAP documentation or use the SQL console to determine the list of allowed scalar types for your specific S/4HANA version. Common allowed types include INT, VARCHAR, DECIMAL, DATE, TIMESTAMP, etc.
Refer to SAP Note 2316073 for a general overview of SQLScript capabilities in S/4HANA.
4
Replace the invalid scalar type with a compatible and allowed type. Ensure data compatibility is maintained.
Corrected Example: DECLARE my_variable VARCHAR(100);
5
Re-execute the SQL script and verify that Error 1310 is resolved.
2. Review Function/Procedure Parameters for Type Compatibility medium
Ensure that all input and output parameters in SQL functions and procedures use supported scalar types.
1
Examine the definition of the SQL function or stored procedure that is causing Error 1310. Pay close attention to the data types declared for its parameters (both input and output).
Example function definition:
2
Identify any parameter types that might be non-standard or custom. These are often the source of the 'Scalar type is not allowed' error.
CREATE FUNCTION calculate_value (input_param MY_NON_STANDARD_TYPE) RETURNS DECIMAL(10,2) AS BEGIN ... END;
3
Cross-reference the declared parameter types with the list of supported scalar types in SAP S/4HANA SQL scripting. Refer to SAP's official documentation for your specific version.
For example, ensure types like 'CLOB' or 'BLOB' are handled appropriately if they are the cause, as direct usage might be restricted in certain contexts.
4
Modify the function or procedure definition to use allowed scalar types for all parameters. If a complex type is needed, consider breaking it down into simpler, supported scalar types or using structures if applicable and supported.
Corrected Example: CREATE FUNCTION calculate_value (input_param VARCHAR(255)) RETURNS DECIMAL(10,2) AS BEGIN ... END;
5
Recompile and re-execute the function or procedure. Test its functionality to confirm the error is gone.
3. Update SAP HANA Database Client and Libraries easy
Ensure that the SAP HANA database client and related libraries used by your applications are up-to-date and compatible with S/4HANA.
1
Identify the SAP HANA database client version and any related libraries (e.g., SAP ADBC drivers, JDBC drivers) that your application or development environment uses to connect to the S/4HANA system.
2
Check SAP's release notes and compatibility matrices to determine the latest recommended versions for your specific SAP S/4HANA version.
Search for 'SAP HANA Client release notes' and 'SAP S/4HANA compatibility matrix'.
3
Download and install the latest compatible SAP HANA database client and any necessary libraries on the application server or development machine.
Example: Download the SAP HANA Client from the SAP Software Download Center.
4
Update the application's connection strings or configuration to point to the new client installation if necessary.
5
Restart the application or development environment and re-run the process that was encountering Error 1310. Outdated clients can sometimes misinterpret or not fully support newer scalar type features.