SAP DB_EXPLAIN_PLAN Function Module for Create an access plan for a given SQL statement
DB_EXPLAIN_PLAN is a standard db explain plan SAP function module available within SAP R/3 or S/4 Hana systems, depending on your version and release level. It is used for Create an access plan for a given SQL statement processing and below is the pattern details for this FM, showing its interface including any import and export parameters, exceptions etc. there is also a full "cut and paste" ABAP pattern code example, along with implementation ABAP coding, documentation and contribution comments specific to this or related objects.
See here to view full function module documentation and code listing for db explain plan FM, simply by entering the name DB_EXPLAIN_PLAN into the relevant SAP transaction such as SE37 or SE38.
Function Group: SYDB_EXPLAIN
Program Name: SAPLSYDB_EXPLAIN
Main Program: SAPLSYDB_EXPLAIN
Appliation area: S
Release date: N/A
Mode(Normal, Remote etc): Normal Function Module
Update:

Function DB_EXPLAIN_PLAN pattern details
In-order to call this FM within your sap programs, simply using the below ABAP pattern details to trigger the function call...or see the full ABAP code listing at the end of this article. You can simply cut and paste this code into your ABAP progrom as it is, including variable declarations.CALL FUNCTION 'DB_EXPLAIN_PLAN'"Create an access plan for a given SQL statement.
EXPORTING
STATEMENT = "SQL statement with markers for host variables
* NO_DISPLAY = ' ' "
* STMT_LG = 0 "
* CON_NAME = ' ' "
TABLES
* VALUES = "Assignment of values to host variables
* PLAN = "Access plan (DB-specific)
* ORA_PAR = "
EXCEPTIONS
EXPLAIN_FAILED = 1
IMPORTING Parameters details for DB_EXPLAIN_PLAN
STATEMENT - SQL statement with markers for host variables
Data type:Optional: No
Call by Reference: Yes
NO_DISPLAY -
Data type:Default: SPACE
Optional: Yes
Call by Reference: No ( called with pass by value option)
STMT_LG -
Data type: IOptional: Yes
Call by Reference: No ( called with pass by value option)
CON_NAME -
Data type: DBCON_NAMEDefault: SPACE
Optional: Yes
Call by Reference: No ( called with pass by value option)
TABLES Parameters details for DB_EXPLAIN_PLAN
VALUES - Assignment of values to host variables
Data type: EXPL_VALUEOptional: Yes
Call by Reference: No ( called with pass by value option)
PLAN - Access plan (DB-specific)
Data type: EXPL_PLANOptional: Yes
Call by Reference: No ( called with pass by value option)
ORA_PAR -
Data type: ORAEXPLPAROptional: Yes
Call by Reference: Yes
EXCEPTIONS details
EXPLAIN_FAILED - Error when creating the plan
Data type:Optional: No
Call by Reference: No ( called with pass by value option)
Copy and paste ABAP code example for DB_EXPLAIN_PLAN Function Module
The ABAP code below is a full code listing to execute function module POPUP_TO_CONFIRM including all data declarations. The code uses the original data declarations rather than the latest in-line data DECLARATION SYNTAX but I have included an ABAP code snippet at the end to show how declarations would look using the newer method of declaring data variables on the fly. This will allow you to compare and fully understand the new inline method. Please note some of the newer syntax such as the @DATA is not available until a later 4.70 service pack (SP8), which i why i have stuck to the origianl for this example.| DATA: | ||||
| lt_values | TYPE STANDARD TABLE OF EXPL_VALUE, " | |||
| lv_statement | TYPE EXPL_VALUE, " | |||
| lv_explain_failed | TYPE EXPL_VALUE, " | |||
| lt_plan | TYPE STANDARD TABLE OF EXPL_PLAN, " | |||
| lv_no_display | TYPE EXPL_PLAN, " SPACE | |||
| lt_ora_par | TYPE STANDARD TABLE OF ORAEXPLPAR, " | |||
| lv_stmt_lg | TYPE I, " 0 | |||
| lv_con_name | TYPE DBCON_NAME. " SPACE |
|   CALL FUNCTION 'DB_EXPLAIN_PLAN' "Create an access plan for a given SQL statement |
| EXPORTING | ||
| STATEMENT | = lv_statement | |
| NO_DISPLAY | = lv_no_display | |
| STMT_LG | = lv_stmt_lg | |
| CON_NAME | = lv_con_name | |
| TABLES | ||
| VALUES | = lt_values | |
| PLAN | = lt_plan | |
| ORA_PAR | = lt_ora_par | |
| EXCEPTIONS | ||
| EXPLAIN_FAILED = 1 | ||
| . " DB_EXPLAIN_PLAN | ||
ABAP code using 7.40 inline data declarations to call FM DB_EXPLAIN_PLAN
The below ABAP code uses the newer in-line data declarations. This allows you to see the coding differences/benefits of the later inline syntax. Please note some of the newer syntax below, such as the @DATA is not available until 4.70 EHP 8.| DATA(ld_no_display) | = ' '. | |||
| DATA(ld_con_name) | = ' '. | |||
Search for further information about these or an SAP related objects