SAP SXPG_CALL_SYSTEM Function Module for Execute an External Command









SXPG_CALL_SYSTEM is a standard sxpg call system SAP function module available within SAP R/3 or S/4 Hana systems, depending on your version and release level. It is used for Execute an External Command 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 sxpg call system FM, simply by entering the name SXPG_CALL_SYSTEM into the relevant SAP transaction such as SE37 or SE38.

Function Group: SXPT
Program Name: SAPLSXPT
Main Program: SAPLSXPT
Appliation area: S
Release date: 29-May-2000
Mode(Normal, Remote etc): Remote-Enabled
Update:



Function SXPG_CALL_SYSTEM 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 'SXPG_CALL_SYSTEM'"Execute an External Command
EXPORTING
COMMANDNAME = "Name of External Command
* ADDITIONAL_PARAMETERS = ' ' "Arguments for the External Command
* TRACE = "Control indicator for external programs (trace level)

IMPORTING
STATUS = "Status of External Command
EXITCODE = "

TABLES
EXEC_PROTOCOL = "Output of External Command

EXCEPTIONS
NO_PERMISSION = 1 TOO_MANY_PARAMETERS = 10 ILLEGAL_COMMAND = 11 COMMAND_NOT_FOUND = 2 PARAMETERS_TOO_LONG = 3 SECURITY_RISK = 4 WRONG_CHECK_CALL_INTERFACE = 5 PROGRAM_START_ERROR = 6 PROGRAM_TERMINATION_ERROR = 7 X_ERROR = 8 PARAMETER_EXPECTED = 9
.



IMPORTING Parameters details for SXPG_CALL_SYSTEM

COMMANDNAME - Name of External Command

Data type: SXPGCOLIST-NAME
Optional: No
Call by Reference: No ( called with pass by value option)

ADDITIONAL_PARAMETERS - Arguments for the External Command

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

TRACE - Control indicator for external programs (trace level)

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

EXPORTING Parameters details for SXPG_CALL_SYSTEM

STATUS - Status of External Command

Data type: EXTCMDEXEX-STATUS
Optional: No
Call by Reference: No ( called with pass by value option)

EXITCODE -

Data type: EXTCMDEXEX-EXITCODE
Optional: No
Call by Reference: No ( called with pass by value option)

TABLES Parameters details for SXPG_CALL_SYSTEM

EXEC_PROTOCOL - Output of External Command

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

EXCEPTIONS details

NO_PERMISSION - No Authorization to Execute the External Command

Data type:
Optional: No
Call by Reference: Yes

TOO_MANY_PARAMETERS - Impermissible Parameter

Data type:
Optional: No
Call by Reference: Yes

ILLEGAL_COMMAND - Illegal Command

Data type:
Optional: No
Call by Reference: Yes

COMMAND_NOT_FOUND - Command Name Is Not Defined

Data type:
Optional: No
Call by Reference: Yes

PARAMETERS_TOO_LONG - Parameter Longer than 128 Characters

Data type:
Optional: No
Call by Reference: Yes

SECURITY_RISK - Execution Rejected for Security Reasons

Data type:
Optional: No
Call by Reference: Yes

WRONG_CHECK_CALL_INTERFACE - Check Module Does Not Exist

Data type:
Optional: No
Call by Reference: Yes

PROGRAM_START_ERROR - Error while Starting the External Command

Data type:
Optional: No
Call by Reference: Yes

PROGRAM_TERMINATION_ERROR - Returncode of the External Program Contains Errors

Data type:
Optional: No
Call by Reference: Yes

X_ERROR - Reserved

Data type:
Optional: No
Call by Reference: Yes

PARAMETER_EXPECTED - No Additional Arguments Specified

Data type:
Optional: No
Call by Reference: Yes

Copy and paste ABAP code example for SXPG_CALL_SYSTEM 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_status  TYPE EXTCMDEXEX-STATUS, "   
lv_commandname  TYPE SXPGCOLIST-NAME, "   
lt_exec_protocol  TYPE STANDARD TABLE OF BTCXPM, "   
lv_no_permission  TYPE BTCXPM, "   
lv_too_many_parameters  TYPE BTCXPM, "   
lv_illegal_command  TYPE BTCXPM, "   
lv_exitcode  TYPE EXTCMDEXEX-EXITCODE, "   
lv_command_not_found  TYPE EXTCMDEXEX, "   
lv_additional_parameters  TYPE SXPGCOLIST-PARAMETERS, "   SPACE
lv_trace  TYPE EXTCMDEXIM-TRACE, "   
lv_parameters_too_long  TYPE EXTCMDEXIM, "   
lv_security_risk  TYPE EXTCMDEXIM, "   
lv_wrong_check_call_interface  TYPE EXTCMDEXIM, "   
lv_program_start_error  TYPE EXTCMDEXIM, "   
lv_program_termination_error  TYPE EXTCMDEXIM, "   
lv_x_error  TYPE EXTCMDEXIM, "   
lv_parameter_expected  TYPE EXTCMDEXIM. "   

  CALL FUNCTION 'SXPG_CALL_SYSTEM'  "Execute an External Command
    EXPORTING
         COMMANDNAME = lv_commandname
         ADDITIONAL_PARAMETERS = lv_additional_parameters
         TRACE = lv_trace
    IMPORTING
         STATUS = lv_status
         EXITCODE = lv_exitcode
    TABLES
         EXEC_PROTOCOL = lt_exec_protocol
    EXCEPTIONS
        NO_PERMISSION = 1
        TOO_MANY_PARAMETERS = 10
        ILLEGAL_COMMAND = 11
        COMMAND_NOT_FOUND = 2
        PARAMETERS_TOO_LONG = 3
        SECURITY_RISK = 4
        WRONG_CHECK_CALL_INTERFACE = 5
        PROGRAM_START_ERROR = 6
        PROGRAM_TERMINATION_ERROR = 7
        X_ERROR = 8
        PARAMETER_EXPECTED = 9
. " SXPG_CALL_SYSTEM




ABAP code using 7.40 inline data declarations to call FM SXPG_CALL_SYSTEM

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 STATUS FROM EXTCMDEXEX INTO @DATA(ld_status).
 
"SELECT single NAME FROM SXPGCOLIST INTO @DATA(ld_commandname).
 
 
 
 
 
"SELECT single EXITCODE FROM EXTCMDEXEX INTO @DATA(ld_exitcode).
 
 
"SELECT single PARAMETERS FROM SXPGCOLIST INTO @DATA(ld_additional_parameters).
DATA(ld_additional_parameters) = ' '.
 
"SELECT single TRACE FROM EXTCMDEXIM INTO @DATA(ld_trace).
 
 
 
 
 
 
 
 


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!