SAP MSS_EXPLAIN_SQL_STMT Function Module for MS SQL server function to get statistics, showplan for SQL stmt execution.









MSS_EXPLAIN_SQL_STMT is a standard mss explain sql stmt SAP function module available within SAP R/3 or S/4 Hana systems, depending on your version and release level. It is used for MS SQL server function to get statistics, showplan for SQL stmt execution. 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 mss explain sql stmt FM, simply by entering the name MSS_EXPLAIN_SQL_STMT into the relevant SAP transaction such as SE37 or SE38.

Function Group: SMSSDATA
Program Name: SAPLSMSSDATA
Main Program: SAPLSMSSDATA
Appliation area: S
Release date: N/A
Mode(Normal, Remote etc): Remote-Enabled
Update:



Function MSS_EXPLAIN_SQL_STMT 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 'MSS_EXPLAIN_SQL_STMT'"MS SQL server function to get statistics, showplan for SQL stmt execution.
EXPORTING
* CON_NAME = 'DEFAULT' "Logical name of a Database Connection
* SCHEMA = ' ' "Target Schema
* SIMPLE_EXPLAIN = 'X' "
* IO_STATS_ON = 'X' "
* TIME_STATS_ON = 'X' "
* SHOWPLAN_ON = 'X' "
* TRACE_FLAG_LIST = ' ' "
* NO_EXECUTE = "

TABLES
SQLCODE = "MS SQL server structure to get the sp text
SQLEXEC_PLAN = "

EXCEPTIONS
DB_ERROR = 1 INTERNAL_ERROR = 2 NOT_RUNNING_ON_MSSQL = 3 CONNECT_ERROR = 4
.



IMPORTING Parameters details for MSS_EXPLAIN_SQL_STMT

CON_NAME - Logical name of a Database Connection

Data type: DBCON-CON_NAME
Default: 'DEFAULT'
Optional: Yes
Call by Reference: No ( called with pass by value option)

SCHEMA - Target Schema

Data type: MSSSCHEMA
Default: SPACE
Optional: Yes
Call by Reference: No ( called with pass by value option)

SIMPLE_EXPLAIN -

Data type: MSQEXPLAIN-SIMPLEEXPL
Default: 'X'
Optional: Yes
Call by Reference: No ( called with pass by value option)

IO_STATS_ON -

Data type: MSQEXPLAIN-IOSTATSON
Default: 'X'
Optional: Yes
Call by Reference: No ( called with pass by value option)

TIME_STATS_ON -

Data type: MSQEXPLAIN-TIMESTATON
Default: 'X'
Optional: Yes
Call by Reference: No ( called with pass by value option)

SHOWPLAN_ON -

Data type: MSQEXPLAIN-SHOWPLANON
Default: 'X'
Optional: Yes
Call by Reference: No ( called with pass by value option)

TRACE_FLAG_LIST -

Data type: MSQEXPLAIN-TRACEFLAGS
Default: ' '
Optional: Yes
Call by Reference: No ( called with pass by value option)

NO_EXECUTE -

Data type: MSQEXPLAIN-NOEXEC
Optional: Yes
Call by Reference: No ( called with pass by value option)

TABLES Parameters details for MSS_EXPLAIN_SQL_STMT

SQLCODE - MS SQL server structure to get the sp text

Data type: MSQSQLCODE
Optional: No
Call by Reference: Yes

SQLEXEC_PLAN -

Data type: MSQSTPRTXT
Optional: No
Call by Reference: No ( called with pass by value option)

EXCEPTIONS details

DB_ERROR - Some database error occurred.

Data type:
Optional: No
Call by Reference: Yes

INTERNAL_ERROR - Internal ADBC error.

Data type:
Optional: No
Call by Reference: Yes

NOT_RUNNING_ON_MSSQL - Not MSSQL

Data type:
Optional: No
Call by Reference: Yes

CONNECT_ERROR - Can't connect

Data type:
Optional: No
Call by Reference: Yes

Copy and paste ABAP code example for MSS_EXPLAIN_SQL_STMT 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_sqlcode  TYPE STANDARD TABLE OF MSQSQLCODE, "   
lv_con_name  TYPE DBCON-CON_NAME, "   'DEFAULT'
lv_db_error  TYPE DBCON, "   
lv_schema  TYPE MSSSCHEMA, "   SPACE
lt_sqlexec_plan  TYPE STANDARD TABLE OF MSQSTPRTXT, "   
lv_internal_error  TYPE MSQSTPRTXT, "   
lv_simple_explain  TYPE MSQEXPLAIN-SIMPLEEXPL, "   'X'
lv_not_running_on_mssql  TYPE MSQEXPLAIN, "   
lv_io_stats_on  TYPE MSQEXPLAIN-IOSTATSON, "   'X'
lv_connect_error  TYPE MSQEXPLAIN, "   
lv_time_stats_on  TYPE MSQEXPLAIN-TIMESTATON, "   'X'
lv_showplan_on  TYPE MSQEXPLAIN-SHOWPLANON, "   'X'
lv_trace_flag_list  TYPE MSQEXPLAIN-TRACEFLAGS, "   ' '
lv_no_execute  TYPE MSQEXPLAIN-NOEXEC. "   

  CALL FUNCTION 'MSS_EXPLAIN_SQL_STMT'  "MS SQL server function to get statistics, showplan for SQL stmt execution.
    EXPORTING
         CON_NAME = lv_con_name
         SCHEMA = lv_schema
         SIMPLE_EXPLAIN = lv_simple_explain
         IO_STATS_ON = lv_io_stats_on
         TIME_STATS_ON = lv_time_stats_on
         SHOWPLAN_ON = lv_showplan_on
         TRACE_FLAG_LIST = lv_trace_flag_list
         NO_EXECUTE = lv_no_execute
    TABLES
         SQLCODE = lt_sqlcode
         SQLEXEC_PLAN = lt_sqlexec_plan
    EXCEPTIONS
        DB_ERROR = 1
        INTERNAL_ERROR = 2
        NOT_RUNNING_ON_MSSQL = 3
        CONNECT_ERROR = 4
. " MSS_EXPLAIN_SQL_STMT




ABAP code using 7.40 inline data declarations to call FM MSS_EXPLAIN_SQL_STMT

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.

 
"SELECT single CON_NAME FROM DBCON INTO @DATA(ld_con_name).
DATA(ld_con_name) = 'DEFAULT'.
 
 
DATA(ld_schema) = ' '.
 
 
 
"SELECT single SIMPLEEXPL FROM MSQEXPLAIN INTO @DATA(ld_simple_explain).
DATA(ld_simple_explain) = 'X'.
 
 
"SELECT single IOSTATSON FROM MSQEXPLAIN INTO @DATA(ld_io_stats_on).
DATA(ld_io_stats_on) = 'X'.
 
 
"SELECT single TIMESTATON FROM MSQEXPLAIN INTO @DATA(ld_time_stats_on).
DATA(ld_time_stats_on) = 'X'.
 
"SELECT single SHOWPLANON FROM MSQEXPLAIN INTO @DATA(ld_showplan_on).
DATA(ld_showplan_on) = 'X'.
 
"SELECT single TRACEFLAGS FROM MSQEXPLAIN INTO @DATA(ld_trace_flag_list).
DATA(ld_trace_flag_list) = ' '.
 
"SELECT single NOEXEC FROM MSQEXPLAIN INTO @DATA(ld_no_execute).
 


Search for further information about these or an SAP related objects



Comments on this SAP object

What made you want to lookup this SAP object? Please tell us what you were looking for and anything you would like to be included on this page!