SAP Function SXPG_CALL_SYSTEM - Execute an External Command

Parameter Reference Type Length Default Optional Text
ADDITIONAL_PARAMETERS SXPGCOLIST-PARAMETERS C 255 SPACE X Arguments for the External Command
COMMANDNAME SXPGCOLIST-NAME C 18 Name of External Command
TRACE EXTCMDEXIM-TRACE C 1 X Control indicator for external programs (trace level)

Parameter Reference Type Length Text
EXITCODE EXTCMDEXEX-EXITCODE I 4
STATUS EXTCMDEXEX-STATUS C 1 Status of External Command

Parameter Reference Length Optional Text
EXEC_PROTOCOL BTCXPM 131 Output of External Command

Exception Text
COMMAND_NOT_FOUND Command Name Is Not Defined
ILLEGAL_COMMAND Illegal Command
NO_PERMISSION No Authorization to Execute the External Command
PARAMETERS_TOO_LONG Parameter Longer than 128 Characters
PARAMETER_EXPECTED No Additional Arguments Specified
PROGRAM_START_ERROR Error while Starting the External Command
PROGRAM_TERMINATION_ERROR Returncode of the External Program Contains Errors
SECURITY_RISK Execution Rejected for Security Reasons
TOO_MANY_PARAMETERS Impermissible Parameter
WRONG_CHECK_CALL_INTERFACE Check Module Does Not Exist
X_ERROR Reserved


This text was copied from IO BCLOG01_007, folder HELP.BCDWBLIB

Functionality
SXPG_CALL_SYSTEM: Execute External Command (Express Method)
Using this function module, you can:

  • Check a user's authorization to execute a command

  • Execute the command

  • To determine the system on which the command should be executed, thefunction module uses by default the current host system and the currentoperating system type of the user.
    As the function module is RFC-capable, you can use the RFC interface(Remote Function Call Interface) to run the function module in adifferent SAP application server. The external command is thenaccordingly executed in the host system of the other SAP server.
    SXPG_CALL_SYSTEM uses the following rules to determine which variant ofa command is used for the execution:
    • If a command with the same operating system type as the one in the
    • sytem field SY-OPSYS exists, this definition is used for the executionof the command.
      • If the first check fails, the syntax group for SY-OPSYS is determined.
      • A syntax group is an SAP construct that groups operating systems thatuse the same syntax for commands and filenames. If a command whoseoperating system type matches the determined syntax group, thisdefinition of the command is used.
        • If no matching definition is found for the syntax group, the function
        • module searches for a definition with the operating system type ANYOS(executable in all supported operating systems). This definition isthen used, if found.
          • Otherwise, the exception COMMAND_NOT_FOUND is triggered.
          • Use

            Syntax:
            CALL FUNCTION SXPG_CALL_SYSTEM
            IMPORTING
            COMMANDNAME = DEFAULT '*'

            ADDITIONAL_PARAMETERS = default
            EXPORTING
            STATUS =
            TABLES
            EXEC_PROTOCOL = In structure BTCXPM. Can,,,,,,,,,,,,,,contain STDOUT, STDERR

            EXCEPTIONS
            NO_PERMISSION Command rejected by User exit auth.

            check
            COMMAND_NOT_FOUND Command not defined in SAP database

            PARAMETERS_TOO_LONG Complete parameter string exceeds,,,,,,,, 128 characters
            SECURITY_RISK Security check failed
            WRONG_CHECK_CALL_INTERFACE Problem with function
            module for additionalsecurity check
            PROGRAM_START_ERROR Error while starting program
            PROGRAM_TERMINATION_ERROR Error while requesting final

            status of program
            X_ERROR Reserved
            PARAMETER_EXPECTED Required parameter not specified

            TOO_MANY_PARAMETERS User arguments not allowed by

            supplied in call
            ILLEGAL_COMMAND Command not legitimately defined
            OTHERS


            This text was copied from IO BCLOG01_007, folder HELP.BCDWBLIB

            Description
            Returns the status after execution of the external command:

            • Value 'O': The external command was started and successfully executed.

            • Value 'E': An error; the external command was not executed
            • successfully.
              This text was copied from IO BCLOG01_007, folder HELP.BCDWBLIB

              Description
              Arguments for the external command as specified by the definition inthe SAP system and the calling program or user.
              These arguments are checked for impermissible characters, such as ;
              under UNIX. Problems are registered with the SECURITY_RISKexception.
              This text was copied from IO BCLOG01_007, folder HELP.BCDWBLIB

              Description
              The name of the definition of the external command, as specified in themaintenance function (Transaction SM69).
              This text was copied from IO BCLOG01_007, folder HELP.BCDWBLIB

              Description
              Contains the STDOUT and STDERR output of the external command and anyoutput data from the target host system.

1152084Parameter for external commands
1265997RR-Interface: File creation with parallel process
988038External commands: Control flag "Wait for termination"
677435Overview: external programs and external commands