SAP Function SXPG_COMMAND_EXECUTE - Execute an External Command

Parameter Reference Type Length Default Optional Text
ADDITIONAL_PARAMETERS SXPGCOLIST-PARAMETERS C 255 X Arguments for the External Command
COMMANDNAME SXPGCOLIST-NAME C 18 Name of External Command
DESTINATION RFCDES-RFCDEST C 32 X
DIALOG BTCH0000-CHAR1 C 1 X Reference type CHAR1 for background processing
OPERATINGSYSTEM SXPGCOLIST-OPSYSTEM C 10 SY-OPSYS X Executing Host System
STDERR EXTCMDEXIM-STDERR C 1 'X' X Log STDERR Output Data
STDOUT EXTCMDEXIM-STDOUT C 1 'X' X Log STDOUT Output Data
TARGETSYSTEM RFCDISPLAY-RFCHOST C 1024 SY-HOST X Target System
TERMINATIONWAIT EXTCMDEXIM-TERMWAIT C 1 'X' X Wait for Termination of Exteranl Command
TRACE EXTCMDEXIM-TRACE C 1 X Perform Trace (Only for Tests)

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

Parameter Reference Length Optional Text
EXEC_PROTOCOL BTCXPM 131 X

Exception Text
CANT_ENQ_TBTCO_ENTRY Reserved
COMMAND_NOT_FOUND External Command Not Defined
ILLEGAL_COMMAND External Command Not Defined Properly
JOBCOUNT_GENERATION_ERROR Reserved
NO_PERMISSION User Does Not Have Authorization
PARAMETERS_TOO_LONG Parameters Too Long
PARAMETER_EXPECTED No Additional Arguments Specified
PROGRAM_START_ERROR Error while Starting the External Command
PROGRAM_TERMINATION_ERROR Return Code with Errors
SECURITY_RISK Command Rejected for Security Reasons
TOO_MANY_PARAMETERS Too Many Parameters Specified
WRONG_ASYNCHRONOUS_PARAMETERS Reserved
WRONG_CHECK_CALL_INTERFACE Incorrect Call of a Function Module
X_ERROR Reserved


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

Functionality
Using this function module, you can check the authorization of a userto execute a particular external command and run the command:

  • With the arguments specified in ADDITIONAL_PARAMETERS

  • On the target host system defined by OPERATINGSYSTEM and TARGETSYSTEM

  • If an SAP profile parameter is inserted in the portion of the commandstored in the database, then the value of this parameter is substitutedinto the command. If an SAP application server is active on the targetsystem (TARGETSYSTEM), then the profile parameter values are read fromthe profile that is active on that system. No parameter substitution ismade in ADDITIONAL_PARAMETERS.
    After substitution, the command is checked for the presence of"dangerous" characters such as the semicolon ( ; ) on UNIX systems.
    If an additional "security function module" is specified in the commanddefinition, this function module is also called in the course ofprocessingebenfalls. This function module can prevent execution of thecommand.
    If the authorization checks complete successfully, the command is runon the target host system.

    Description
    Exitcode of the external command
    This text was copied from IO BCLOG01_005, folder HELP.BCDWBLIB

    Description
    Returns the final status of the execution of the external command:
    If the include RSXPGDEF is called in your program, there are thefollowing possible values:

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

    • Value 'F': Error; the external command was not executed.

    • Value 'E': Error, the external command was terminated with an error.

    • Value 'S': The external command was terminated due to an operating
    • system message.
      • Value 'C': The external command was terminated in an unknown way.

      • If you do not use RSXPGDEF, only the following values can be deliveredback:
        • Value 'O': The external command was started and successfully run.

        • Value 'E': Error, the external command was not executed

        • This text was copied from IO BCLOG01_005, folder HELP.BCDWBLIB

          Description
          Arguments for the external program as specified by the calling programor user. These arguments are appended to any arguments specified in thedefinition of the command (DEFINED_PARAMETERS).
          These arguments are checked for impermissible characters, such as ;under UNIX. Problems are registered with the SECURITY_RISK exception.
          This text was copied from IO BCLOG01_005, 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_005, folder HELP.BCDWBLIB

          Description
          Host system, in which the command is to be run. OPERATINGSYSTEM isspecified in the command definition (Transaction SM69).
          This text was copied from IO BCLOG01_005, folder HELP.BCDWBLIB

          Description
          Log of STDERR output from the external command in EXEC_PROTOCOL, if setto a non-space value. If set to space, then STDOUT is ignored.
          Logging is only possible if the value for TERMINATIONWAIT has anon-space value (Wait for termination).
          This text was copied from IO BCLOG01_005, folder HELP.BCDWBLIB

          Description
          Log of STDERR output from the external command in EXEC_PROTOCOL, if setto a non-space value. If set to space, then STDOUT is ignored.
          Logging is only possible if the value for TERMINATIONWAIT has anon-space value (Wait for termination).
          This text was copied from IO BCLOG01_005, folder HELP.BCDWBLIB

          Description
          TARGETSYSTEM is the name of the system, in which the command is to berun.
          For more information, see: Prerequisites forexecuting external programs
          This text was copied from IO BCLOG01_005, folder HELP.BCDWBLIB

          Description
          Wait for termination of external command.
          If set to space, the command is started asynchronously and no output iscollected from the command or from the target host system.
          If set to a value other than space, the function module waits for theexternal command to complete. It also logs STDOUT and STDERR, ifrequested, in EXEC_PROTOCOL, if the TARGETSYSTEM returns this output.
          This text was copied from IO BCLOG01_005, folder HELP.BCDWBLIB

          Description
          Trace execution through CALL 'writetrace' and the local trace functionof the external commands interface itself.
          If set to space ' ', no trace is carried out. Otherwise, tracing isactive
          Should be used ONLY for testing. The setting of this argument has noeffect on the trace specification in the defitinition of the externalcommand (Transaction SM69).

          Description
          Contains the STDOUT and STDERR output for the external command andoutput data of the target host system, if TERMINATIONWAIT is active.

854060Authorizations for external commands
446172SXPG_COMMAND_EXECUTE (program_start_error) in DB13
1152084Parameter for external commands
1265997RR-Interface: File creation with parallel process
1128667SXPG_COMMAND_EXECUTE: Parameters STATUS and EXITCODE
980266RFC destination SAPXPG_DBDEST_<DB-HOST> does not work
988038External commands: Control flag "Wait for termination"
936683Specify full path name when starting program
677435Overview: external programs and external commands
188772External program does not work
583759R/3 error when you start jobs from DB13