SAP GET_DB4_CUR_SQL Function Module for Get the actual SQL Statement
GET_DB4_CUR_SQL is a standard get db4 cur sql SAP function module available within SAP R/3 or S/4 Hana systems, depending on your version and release level. It is used for Get the actual 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 get db4 cur sql FM, simply by entering the name GET_DB4_CUR_SQL into the relevant SAP transaction such as SE37 or SE38.
Function Group: STU4
Program Name: SAPLSTU4
Main Program: SAPLSTU4
Appliation area:
Release date: N/A
Mode(Normal, Remote etc): Remote-Enabled
Update:

Function GET_DB4_CUR_SQL 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 'GET_DB4_CUR_SQL'"Get the actual SQL Statement.
EXPORTING
* PID = "iSeries: Process ID of a Work Process
IMPORTING
CURSQL_LEN = "Length of the Current SQL Statement
CURSQL = "
EXCEPTIONS
DATABASE_JOB_NOT_FOUND = 1 API_ERROR = 2 NO_WP_NUMBER = 3 NO_WP_LIST = 4 DATABASE_NOT_SUPPORTED = 5
IMPORTING Parameters details for GET_DB4_CUR_SQL
PID - iSeries: Process ID of a Work Process
Data type: DB4DBJOBS-PIDOptional: Yes
Call by Reference: No ( called with pass by value option)
EXPORTING Parameters details for GET_DB4_CUR_SQL
CURSQL_LEN - Length of the Current SQL Statement
Data type: CURSQLLENOptional: No
Call by Reference: No ( called with pass by value option)
CURSQL -
Data type: STRINGOptional: No
Call by Reference: No ( called with pass by value option)
EXCEPTIONS details
DATABASE_JOB_NOT_FOUND -
Data type:Optional: No
Call by Reference: Yes
API_ERROR -
Data type:Optional: No
Call by Reference: Yes
NO_WP_NUMBER -
Data type:Optional: No
Call by Reference: Yes
NO_WP_LIST -
Data type:Optional: No
Call by Reference: Yes
DATABASE_NOT_SUPPORTED -
Data type:Optional: No
Call by Reference: Yes
Copy and paste ABAP code example for GET_DB4_CUR_SQL 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: | ||||
| lv_pid | TYPE DB4DBJOBS-PID, " | |||
| lv_cursql_len | TYPE CURSQLLEN, " | |||
| lv_database_job_not_found | TYPE CURSQLLEN, " | |||
| lv_cursql | TYPE STRING, " | |||
| lv_api_error | TYPE STRING, " | |||
| lv_no_wp_number | TYPE STRING, " | |||
| lv_no_wp_list | TYPE STRING, " | |||
| lv_database_not_supported | TYPE STRING. " |
|   CALL FUNCTION 'GET_DB4_CUR_SQL' "Get the actual SQL Statement |
| EXPORTING | ||
| PID | = lv_pid | |
| IMPORTING | ||
| CURSQL_LEN | = lv_cursql_len | |
| CURSQL | = lv_cursql | |
| EXCEPTIONS | ||
| DATABASE_JOB_NOT_FOUND = 1 | ||
| API_ERROR = 2 | ||
| NO_WP_NUMBER = 3 | ||
| NO_WP_LIST = 4 | ||
| DATABASE_NOT_SUPPORTED = 5 | ||
| . " GET_DB4_CUR_SQL | ||
ABAP code using 7.40 inline data declarations to call FM GET_DB4_CUR_SQL
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 PID FROM DB4DBJOBS INTO @DATA(ld_pid). | ||||
Search for further information about these or an SAP related objects