SAP SRGUI_INVOKE Function Module for Invoke and assign a SAPGUI to the current ABAP session
SRGUI_INVOKE is a standard srgui invoke SAP function module available within SAP R/3 or S/4 Hana systems, depending on your version and release level. It is used for Invoke and assign a SAPGUI to the current ABAP session 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 srgui invoke FM, simply by entering the name SRGUI_INVOKE into the relevant SAP transaction such as SE37 or SE38.
Function Group: REMOTE_SAPGUI
Program Name: SAPLREMOTE_SAPGUI
Main Program: SAPLREMOTE_SAPGUI
Appliation area:
Release date: N/A
Mode(Normal, Remote etc): Normal Function Module
Update:

Function SRGUI_INVOKE 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 'SRGUI_INVOKE'"Invoke and assign a SAPGUI to the current ABAP session.
EXPORTING
PROGID = "Program-ID of a registered RFC server
* GWHOST = "Gateway Host Name
* GWSERV = "Gateway service
* USING_SNC = ' ' "X: Using SNC
* SERVER_ID = ' ' "if not space: CHECKID from RFC Server must match this ID
* JCO_SERVER = ' ' "X: registered JCO Server
IMPORTING
RFCDEST = "Internal Destination to the RFC Server
EXCEPTIONS
RFC_SERVER_NOT_READY = 1 INVOKE_SAPGUI_NOT_SUPPORTED = 2 SERVER_ID_CHECK_FAILED = 3
IMPORTING Parameters details for SRGUI_INVOKE
PROGID - Program-ID of a registered RFC server
Data type: COptional: No
Call by Reference: Yes
GWHOST - Gateway Host Name
Data type: COptional: Yes
Call by Reference: Yes
GWSERV - Gateway service
Data type: COptional: Yes
Call by Reference: Yes
USING_SNC - X: Using SNC
Data type: SY-INPUTDefault: SPACE
Optional: Yes
Call by Reference: Yes
SERVER_ID - if not space: CHECKID from RFC Server must match this ID
Data type: RFCOPT-RFCEXECDefault: SPACE
Optional: Yes
Call by Reference: Yes
JCO_SERVER - X: registered JCO Server
Data type: SY-INPUTDefault: SPACE
Optional: Yes
Call by Reference: Yes
EXPORTING Parameters details for SRGUI_INVOKE
RFCDEST - Internal Destination to the RFC Server
Data type: RFCDES-RFCDESTOptional: No
Call by Reference: Yes
EXCEPTIONS details
RFC_SERVER_NOT_READY - RFC-Server is not register or not ready.
Data type:Optional: No
Call by Reference: Yes
INVOKE_SAPGUI_NOT_SUPPORTED - RFC-Server doesnot support invoking SAPGUI.
Data type:Optional: No
Call by Reference: Yes
SERVER_ID_CHECK_FAILED - SERVER_ID doesn't match
Data type:Optional: No
Call by Reference: Yes
Copy and paste ABAP code example for SRGUI_INVOKE 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_progid | TYPE C, " | |||
| lv_rfcdest | TYPE RFCDES-RFCDEST, " | |||
| lv_rfc_server_not_ready | TYPE RFCDES, " | |||
| lv_gwhost | TYPE C, " | |||
| lv_invoke_sapgui_not_supported | TYPE C, " | |||
| lv_gwserv | TYPE C, " | |||
| lv_server_id_check_failed | TYPE C, " | |||
| lv_using_snc | TYPE SY-INPUT, " SPACE | |||
| lv_server_id | TYPE RFCOPT-RFCEXEC, " SPACE | |||
| lv_jco_server | TYPE SY-INPUT. " SPACE |
|   CALL FUNCTION 'SRGUI_INVOKE' "Invoke and assign a SAPGUI to the current ABAP session |
| EXPORTING | ||
| PROGID | = lv_progid | |
| GWHOST | = lv_gwhost | |
| GWSERV | = lv_gwserv | |
| USING_SNC | = lv_using_snc | |
| SERVER_ID | = lv_server_id | |
| JCO_SERVER | = lv_jco_server | |
| IMPORTING | ||
| RFCDEST | = lv_rfcdest | |
| EXCEPTIONS | ||
| RFC_SERVER_NOT_READY = 1 | ||
| INVOKE_SAPGUI_NOT_SUPPORTED = 2 | ||
| SERVER_ID_CHECK_FAILED = 3 | ||
| . " SRGUI_INVOKE | ||
ABAP code using 7.40 inline data declarations to call FM SRGUI_INVOKE
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 RFCDEST FROM RFCDES INTO @DATA(ld_rfcdest). | ||||
| "SELECT single INPUT FROM SY INTO @DATA(ld_using_snc). | ||||
| DATA(ld_using_snc) | = ' '. | |||
| "SELECT single RFCEXEC FROM RFCOPT INTO @DATA(ld_server_id). | ||||
| DATA(ld_server_id) | = ' '. | |||
| "SELECT single INPUT FROM SY INTO @DATA(ld_jco_server). | ||||
| DATA(ld_jco_server) | = ' '. | |||
Search for further information about these or an SAP related objects