Error
Error Code: 1361

SAP S/4HANA Error 1361: Incorrect SQLScript Pragma Directive

📦 SAP S/4HANA
📋

Description

This error indicates that an invalid or unrecognized PRAGMA statement was encountered within an SQLScript procedure, function, or view. It typically occurs during compilation or execution when the SQLScript parser cannot interpret a specified directive, often due to syntax errors, unsupported pragmas, or incorrect placement.
💬

Error Message

ERR_SQLSCRIPT_INVALID_PRAGMA
🔍

Known Causes

3 known causes
⚠️
Incorrect Pragma Syntax
The PRAGMA statement contains a typo, incorrect syntax, or missing arguments, preventing the SQLScript parser from recognizing it.
⚠️
Unsupported Pragma Directive
An attempt was made to use a PRAGMA directive that is not supported in the current version of SAP HANA SQLScript or the specific database context.
⚠️
Misplaced Pragma Statement
The PRAGMA statement is placed in a context or scope within the SQLScript code where it is not allowed or expected.
🛠️

Solutions

4 solutions available

1. Correct SQLScript Pragma Syntax easy

Review and correct any typos or incorrect syntax in the SQLScript pragma directives.

1
Identify the SQLScript code that is causing the error. This is typically found in stored procedures, functions, or CDS views with SQLScript logic.
2
Locate any pragma directives within the identified SQLScript code. Pragmas usually start with '#pragma'.
3
Verify the spelling and syntax of each pragma. Common incorrect pragmas might include typos or incorrect arguments. For example, ensure '#pragma name(value)' is correctly formatted.
4
Refer to the SAP HANA SQLScript documentation for the correct syntax of all supported pragmas. Ensure you are using valid pragma names and their expected parameters.
5
Recompile or activate the SQLScript object after correcting the pragma syntax. If the error persists, proceed to the next solution.

2. Remove or Comment Out Problematic Pragmas easy

Temporarily disable suspect pragmas to isolate the issue.

1
Locate the SQLScript code containing the error.
2
Identify pragma directives that might be causing the issue. If you suspect a specific pragma, start with that one.
3
Comment out the suspected pragma directive by placing '--' before it or using block comments if applicable.
4
Example of commenting out a pragma:
sql
-- #pragma use_plan_cache
5
Recompile or activate the SQLScript object. If the error is resolved, you have found the problematic pragma. You can then investigate its correct usage or decide if it's essential for your logic.
6
If commenting out one pragma doesn't resolve the error, try commenting out other pragmas one by one until the error is gone.

3. Ensure Pragma Compatibility with HANA Version medium

Verify that the pragmas used are supported by your specific SAP HANA/S/4HANA database version.

1
Determine the exact version of your SAP HANA database and the corresponding SAP S/4HANA release.
2
Consult the SAP HANA SQL and System Views Reference documentation for your specific database version. Look for sections detailing SQLScript pragmas.
3
Compare the pragmas used in your SQLScript code against the list of supported pragmas for your HANA version. Some pragmas might be deprecated or have changed their syntax in newer versions.
4
If you find an unsupported pragma, either remove it or replace it with an equivalent or newer directive if available. Consult SAP Notes for any version-specific recommendations.
5
Recompile or activate the SQLScript object after making the necessary adjustments.

4. Review and Correct Custom SQLScript Objects medium

Thoroughly inspect user-defined SQLScript objects for incorrect pragma usage.

1
Identify all custom-developed stored procedures, functions, and CDS views that utilize SQLScript.
2
For each custom object, retrieve its source code using tools like SAP HANA Studio, SAP Business Application Studio, or SQL commands (e.g., `SELECT * FROM PROCEDURES WHERE PROCEDURE_NAME = 'YOUR_PROCEDURE_NAME'`).
3
Carefully examine all pragma directives within these custom objects. Pay close attention to:
- Typos in pragma names (e.g., `#pragma use_plan_cache` vs. `#pragma use_plan_cachee`).
- Incorrect arguments or values for pragmas.
- Pragmas that are no longer supported in your HANA version.
- Incorrect placement of pragmas (they usually appear at the beginning of the script).
4
Use the SAP HANA documentation as a reference for correct pragma syntax and usage.
5
Correct any identified syntax errors, invalid pragmas, or unsupported directives.
6
Recompile and test each modified SQLScript object individually to ensure the error is resolved.
🔗

Related Errors

5 related errors