sapdev logo background
sapdev logo sapdev logo
Comments

sxpg_command_execute FM to Execute external commands (FTP Scripts)




The following code shows the syntax of the FM 'SXPG_COMMAND_EXECUTE'. You pass it the external command created within transaction SM69 and it will execute it.

DATA: ld_comline  LIKE sxpgcolist-name,
        ld_param    LIKE sxpgcolist-parameters,
        ld_status   LIKE extcmdexex-status,
        ld_output   LIKE btcxpm OCCURS 0 WITH HEADER LINE,
        ld_subrc    LIKE sy-subrc.

  REFRESH ld_output.
  MOVE 'FTP_DATA_IN' to ld_comline.         "Maintained using trans SM69

* Execute external command, contained in 'ld_comline'
  CALL FUNCTION 'SXPG_COMMAND_EXECUTE'
       EXPORTING
            commandname                   = ld_comline
*           additional_parameters   = ld_param  "Params passed to script
*           operatingsystem               = 'UNIX'
       IMPORTING
            status                        = ld_status
       TABLES
            exec_protocol                 = ld_output
       EXCEPTIONS
            no_permission                 = 1
            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
            too_many_parameters           = 10
            illegal_command               = 11
            wrong_asynchronous_parameters = 12
            cant_enq_tbtco_entry          = 13
            jobcount_generation_error     = 14
            OTHERS                        = 15.
  IF sy-subrc NE 0.

  ENDIF.



Check out sap documentation and pattern details for function module sxpg_command_execute on website se80.co.uk



comments powered by Disqus