Error
Error Code:
691
SAP S/4HANA Error 691: Deprecated SQL Plan Stability Command
Description
This error indicates that a command related to SQL plan stability, a feature of the SAP HANA database, is being used but has been deprecated. It typically occurs during database operations or system upgrades when older, unsupported syntax or features are invoked.
Error Message
ERR_SQL_PLAN_STABILITY_COMMAND_DEPRECATED
Known Causes
3 known causesOutdated SQL Syntax
The system is attempting to execute a SQL command or utilize a feature for plan stability that has been marked as deprecated in the current SAP HANA database version.
Unadapted Application Code
Custom or standard application code, including SQL scripts or stored procedures, has not been updated to align with the latest SAP HANA database version's plan stability features.
Database Upgrade Incompatibility
An SAP HANA database upgrade occurred, but dependent applications or custom developments were not adapted to the new database version's API or feature set for SQL plan stability.
Solutions
3 solutions available1. Migrate to SQL Plan Management (SPM) from SQL Plan Stability medium
Replace deprecated SQL Plan Stability commands with their modern SQL Plan Management equivalents.
1
Identify SQL statements using deprecated SQL Plan Stability commands. These are typically found in custom ABAP code or older SAP notes. Look for commands like `ALTER SYSTEM ALTER CONFIGURATION ('indexserver.ini', 'SYSTEM') SET ('SQL_PLAN_STABILITY.ENABLED')='true'` or similar configurations related to plan stability.
2
Understand the equivalent SQL Plan Management (SPM) configuration. SPM is the successor to SQL Plan Stability and offers more granular control. The primary configuration for SPM is typically managed through the `indexserver.ini` (or equivalent for your HANA version) under the `SQL_PLAN_MANAGEMENT` section.
Example configuration for SPM (ensure this is applied via SAP HANA cockpit or SQL console):
[SQL_PLAN_MANAGEMENT]
ENABLED = TRUE
[SQL_PLAN_STABILITY]
ENABLED = FALSE // Ensure this is disabled to avoid conflicts
3
Use SQL Plan Management (SPM) to capture and manage execution plans. Instead of relying on the implicit behavior of the deprecated stability commands, actively manage plans using SPM. This involves creating plan versions and binding them to specific SQL statements.
Example SQL to create a plan version (replace placeholders):
CREATE VERSION FOR SQL_STATEMENT 'SELECT * FROM MY_TABLE WHERE COL1 = ?' FROM CACHED PLAN;
Example SQL to bind a plan version:
GRANT PLAN_VERSION '<version_id>' TO '<user>' FOR SQL_STATEMENT 'SELECT * FROM MY_TABLE WHERE COL1 = ?';
4
Decommission and remove any configuration or code explicitly referencing the deprecated SQL Plan Stability commands. This includes checking `indexserver.ini` for any `SQL_PLAN_STABILITY` parameters and removing them.
2. Review and Update SAP Notes and Custom Code medium
Identify and update any SAP Notes or custom ABAP code that might be using deprecated SQL Plan Stability commands.
1
Search for SAP Notes related to SQL Plan Stability and your S/4HANA version. SAP frequently releases notes to address such deprecations and provide migration guidance.
Use the SAP Support Portal and search for terms like 'SQL Plan Stability deprecated', 'Error 691', 'S/4HANA HANA SQL Plan Management'.
2
Analyze custom ABAP programs and reports that interact with the database. Look for any embedded SQL statements or database calls that might be attempting to manipulate SQL plan stability. Pay close attention to older custom developments.
In ABAP, search for keywords like 'ALTER SYSTEM', 'ALTER CONFIGURATION', 'SQL PLAN STABILITY' within your custom code.
3
If custom code is found, refactor it to use SQL Plan Management (SPM) features. This might involve removing direct configuration commands and instead using SPM's capabilities for plan capture and binding. Consult SAP's official documentation for the correct SPM APIs or SQL statements.
4
Apply any relevant SAP Notes that provide corrections or updated guidance for handling SQL plan stability in your S/4HANA environment.
3. Disable SQL Plan Stability Configuration easy
Temporarily disable the deprecated SQL Plan Stability feature to resolve the immediate error.
1
Access the SAP HANA Cockpit or use the SQL console to manage system configurations.
2
Locate the `indexserver.ini` configuration file (or equivalent for your HANA version).
3
Find the `[SQL_PLAN_STABILITY]` section and set `ENABLED` to `false`. If the section or parameter doesn't exist, it might indicate it's not actively used, but it's good practice to ensure it's off if the error persists.
SQL Console command:
ALTER SYSTEM ALTER CONFIGURATION ('indexserver.ini', 'SYSTEM') SET ('SQL_PLAN_STABILITY', 'ENABLED') = 'false';
4
Restart the SAP HANA database or the specific service that manages SQL plans (usually the indexserver). This step is critical for the configuration change to take effect.
Restarting HANA is typically done via SAP Landscape Management (SaLM) or OS commands. Example (Linux):
HDB stop
HDB start
5
Verify that the error 691 is no longer occurring after the restart.