SXPG_COMMAND_EXECUTE exception SECURITY_RISK

Hi Gurus,
  When im executing the function SXPG_COMMAND_EXECUTE calling a command in Unix, im getting the SECURITY_RISK exception.
  Not sure what is the cause of this.
  Thanks in advance

Hi,
Check SAP Note 864152 - Exception SECURITY_RISK with external command
also check Note 686765 - Security check when you execute external commands
regards,
kaushal

Similar Messages

  • FM used to display detail in text.

    Hi all,
             i have a requirement as ,
        on pressing a button(user defined) on app tool bar , i must get an F1 type details.
    Please note : it is not on any field F1

    HI,
    SXPG_DUMMY_COMMAND_CHECK: Interface for Extra-Check Function Modules 
    When you define an external command, you can specify that an additional function module be called to check a user’s authorization to run a command.
    You can define such an additional authorization check module yourself. Your function module must have the interface defined below for SXPG_DUMMY_COMMAND_CHECK. Like this function module, it may only allow or deny permission to carry out the command.
    To ensure that such a user exit function module cannot be misused, the system checks that the interface of the authorization-checking function module matches the interface of SXPG_DUMMY_COMMAND_CHECK. It is therefore essential that SXPG_DUMMY_COMMAND_CHECK never be changed.
    To write your own authorization-checking module, do the following:
    Copy SXPG_DUMMY_COMMAND_CHECK to a name in the customer naming range (names beginning with Y or Z).
    Write your authorization check.
    Specify that the function module should be run when the command that is to be checked is run. Do this in the command definition (transaction SM69).
    Do not change SXPG_DUMMY_COMMAND_CHECK or its interface. Never call this function module, either directly or by specifying it as the check module in a command definition. Copy it and then modify the new function module in order to implement an additional authorization check.
    Interface Syntax:
    IMPORTING
    PROGRAMNAME = <Program or command from definition>
    PARAMETERS = <Argument string>
    EXCEPTIONS
    NO_PERMISSION " Command rejected by user exit auth. check
    Parameters
    IMPORTING Parameters
    Parameter name
    Use
    PROGRAMNAME
    The fully substituted pathname of the external command that is to be run.
    PARAMETERS
    Arguments for the external command as specified by the definition in the R/3 System and by the calling program or user.
    These arguments are checked for impermissible characters, such as the ; under UNIX. Problems are registered with the SECURITY_RISK exception.
    Exceptions
    Exception name
    Meaning
    NO_PERMISSION
    Prevents a command from being run if the authorization check that you have implemented in a check module fails.
    NO_PERMISSION triggers the exception SECURITY_RISK in the calling function module.
    Refer this link.
    http://help.sap.com/saphelp_45b/helpdata/en/fa/09722f543b11d1898e0000e8322d00/frameset.htm

  • Problem on 'SXPG_CALL_SYSTEM' function

    concatenate ' -classpath . -jar'
                  ' /TEST/test.jar'
                  string_arg
                  INTO COMMAND_STR.
    CALL FUNCTION 'SXPG_CALL_SYSTEM'
       EXPORTING COMMANDNAME   = 'ZJAVA'
            ADDITIONAL_PARAMETERS = COMMAND_STR
             TABLES    EXEC_PROTOCOL = IT_BTCXPM
             EXCEPTIONS
                SECURITY_RISK = 1.
       IF SY-SUBRC <> 0.
          WRITE : 'Make directory error !'.
       ENDIF.
    I try using this function for execute external command.
    and succesfully done before.
    but the problem is sometimes 'string_arg' is exceed 255 charactor long.
    ADDITIONAL_PARAMETERS type can hold only 255 charactor long.
    is there any function can excute UNIX command with more than 255 charactor parameter?
    or any other way to solve this problem?
    thank you

    Hi,
    Not Sure then how to solve.........,
    if the String is more than 255 chars..
    Regards
    Vijay
    Message was edited by: Vijay Babu Dudla

  • Problem with FM SXPG_COMMAND_EXECUTE in deleting a file on server.

    Hi All,
    My Task is to delete a file with version number 6 and rename all other files, so that my new file will be version 0.
    Am using the FM SXPG_COMMAND_EXECUTE to delete/rename a file on server.
    Though, this is working fine in debugging mode I can see the file getting deleted in regular run, which is followed by renaming some files, it is NOT working in regular run.
    Somehow the deletion and renaming are not happening correctly in regular run, but does happen successfully while in debugging.
    Am I missing anything or any refresh or delay needed?
    Here is my code for DELETE :
    CONCATENATE P_PATH '\' P_TABNAME '_6.dat' INTO LF_FILE.
      CONDENSE LF_FILE NO-GAPS.
    *// Check if this file exists
      OPEN DATASET LF_FILE FOR INPUT IN TEXT MODE ENCODING DEFAULT.
      IF SY-SUBRC EQ 0.
    *// Delete this file
        DELETE = LF_FILE.
        CALL FUNCTION 'SXPG_COMMAND_EXECUTE'
          EXPORTING
            ADDITIONAL_PARAMETERS      = DELETE
            COMMANDNAME                = 'ZDELETE'
            OPERATINGSYSTEM            = OPSYS
            STDERR                     = 'X'
            STDOUT                     = 'X'
            TARGETSYSTEM               = EHOST
            TERMINATIONWAIT            = TERMWAIT
            TRACE                      = ' '
          IMPORTING
            STATUS                     = RETCODE
          TABLES
            EXEC_PROTOCOL              = PROT
          EXCEPTIONS
            COMMAND_NOT_FOUND          = 01
            NO_PERMISSION              = 02
            PARAMETERS_TOO_LONG        = 03
            PARAMETER_EXPECTED         = 04
            PROGRAM_START_ERROR        = 05
            PROGRAM_TERMINATION_ERROR  = 06
            SECURITY_RISK              = 07
            TOO_MANY_PARAMETERS        = 08
            WRONG_CHECK_CALL_INTERFACE = 09
            X_ERROR                    = 10
            OTHERS                     = 11.
    ENDIF.
    Regards
    Raj
    Edited by: Rajasekhar Dinavahi on Apr 14, 2010 11:45 AM

    Hi All,
    Problem resolved.
    We need ensure all files which are opened [by OPEN DATASET], are CLOSED before trying any operation like DELETE or RENAME on the files.
    Regards
    Raj

  • PROBLEM IN SXPG_COMMAND_EXECUTE

    Hi,
    Can anyone solve my problem I m using function module to zip three excel sheet which were present in the application file and shell script is written accordingly.
    But my query is this is working fine in Production and in development but it is failing in Quality with SU 53 screen shot showing auth. object S_RZL_ADM Object class BC_A with acticvity 01 is highlighted in red.
    Does these are in correspondence with each other?
    CALL FUNCTION 'SXPG_COMMAND_EXECUTE'
        EXPORTING
          commandname                   = c_zcompressall
          additional_parameters         = w_missingtargz
          stdout                                = c_x
          stderr                                 = c_x
          terminationwait                   = c_x
        TABLES
          exec_protocol                 = w_protocol
        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.
    Here after executing the w_protocol is giving me two values
    1.Can't exec external program (No such file or directory) 
    2.External program terminated with exit code 1
    Would please suggest me why it is happening?
    regards
    M jacks

    Hi All,
    There is a Quality refresh happened which means the Production data overwrites the Quality In such case the path that is defined in SM69 of the external command Zcompressall got overwrite with the production path which is the reason for failing of the external command.
    Cheers
    Jacks M.

  • SXPG_COMMAND_EXECUTE

    Hi Experts,
    Can you explain me the fuctionality below code...
    DATA: l_target_syst     LIKE rfcdisplay-rfchost.
      DATA: i_error LIKE btcxpm  OCCURS 0 WITH HEADER LINE.
      CALL 'C_SAPGPARAM' ID 'NAME'  FIELD 'SAPDBHOST'
                         ID 'VALUE' FIELD l_target_syst.
      CALL FUNCTION 'SXPG_COMMAND_EXECUTE'
        EXPORTING
          commandname                         = commandname
          additional_parameters               = filename
          operatingsystem                     = sy-opsys
          targetsystem                        = l_target_syst
       DESTINATION                         =
          stdout                              = stdout
          stderr                              = stderr
          terminationwait                     = terminationwait
       TRACE                               =
        IMPORTING
          status                              = status
          exitcode                            = exitcode
        tables
          exec_protocol                       = i_exec_protocol
        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                              = 99.
      CASE sy-subrc.
        WHEN 1.
          RAISE no_permission.
        WHEN 2.
          RAISE command_not_found.
        WHEN 3.
          RAISE parameters_too_long.
        WHEN 4.
          RAISE security_risk.
        WHEN 5.
          RAISE wrong_check_call_interface.
        WHEN 6.
          RAISE program_start_error.
        WHEN 7.
          RAISE program_termination_error.
        WHEN 8.
          RAISE x_error.
        WHEN 9.
          RAISE parameter_expected.
        WHEN 10.
          RAISE too_many_parameters.
        WHEN 11.
          RAISE illegal_command.
        WHEN 12.
          RAISE wrong_asynchronous_parameters.
        WHEN 13.
          RAISE cant_enq_tbtco_entry.
        WHEN 14.
          RAISE jobcount_generation_error.
        WHEN 99.
          RAISE x_error.
      ENDCASE.
    Regards
    Kali Pramod

    In this FM.. main three parameters are:
    <b>commandname
    additional_parameters
    exec_protocol</b>
    Commandname is the command created thru SM49 they are called external operating system command,,,
    In this command first parameter is always an operating system command like..
    <b>ls for listing all files and directories</b>
    <b>put</b>  etc
    in additional_parameters you can pass the parameters for that command like for the command you can see the contents of some particular directory so u have to pass  that directory path in additional_parameters field 
    i.e. additional_parameters = '/usr/sap/tmp'
    and exec_protocol is the table which returns u the contents which are retrieved using that command...
    e.g using ls command all files an dir names appended to this table...
    You can use another FM is ur additional parametes field is very long..
    <b> SXPG_COMMAND_EXECUTE_LONG</b>
    <i>Two more parameters:  STATUS and EXITCODE are very important... your command is run successfully only when <b>STATUS = 'O' " Capital O
    and
    EXITCODE = '0' " Zero</b>
    </i>
    Reward if useful
    Regards
    Prax

  • SXPG_COMMAND_EXECUTE - Recv failed:Connection reset by peer

    We are calling external commands in a batch job using the SAP supplied function module SXPG_COMMAND_EXECUTE.  However, if the external command takes longer than 2 minutes (120 seconds) to execute the call to the external command is terminated (from the SAP perspective) with the message Recv failed:Connection reset by peer.  The termination is precisely at 120 seconds.  The external command, however, continues to run as an u201Corphanu201D task and finishes normally.  However, due to the connection termination, SAP is no longer aware of it.
    Do you have any ideas where the termination is occurring and/or where the wait limit of 120 seconds is set?

    CALL FUNCTION 'SXPG_COMMAND_EXECUTE'
        EXPORTING
          commandname                   = 'ZTEST_BATCH'
          additional_parameters         = param1
          operatingsystem               = castserveropsys
          targetsystem                  = target
          stdout                        = 'X'
          stderr                        = 'X'
          terminationwait               = 'X'
        IMPORTING
          status                        = funcstatus
        TABLES
          exec_protocol                 = iserveroutput[]
        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.

  • SXPG_COMMAND_EXECUTE   FUNCTION

    Hi   Everyone,
    I  have a problem to use this function :
    The unix commande is copyoutbound  .
    I want to copy a file automatically using reflection from a unix path to other unix path.
    But  it  doesn`t work in this test code.
    Can someone help me .
    Thanks a lot
    Soufiene
    REPORT  ZTEST_SOU.
    DATA: params             LIKE sxpgcolist-parameters.
    DATA: return_code        LIKE btcxp3-exitstat.
    DATA: unix_command       LIKE sxpgcolist-name.
    DATA: dest               LIKE rfcdes-rfcdest.
    DATA: FILENAME1(128) TYPE C,
          FILENAME2(128) TYPE C.
    DATA: single_quote(1) TYPE c VALUE '"'.
    DATA: quoted_subject(32) TYPE c.
    DATA: convert_flag(1)    TYPE c.
    DATA: BEGIN OF tabl OCCURS 0.
            INCLUDE STRUCTURE btcxpm.   "Structure for Logging message from
    DATA: END OF tabl.                  "external program to calling program
    DATA: ICN LIKE ICON-ID,
          I_NEXT_DATE LIKE  SY-DATUM,
          I_COMP_DATE LIKE  SY-DATUM,
          T_EXEC      LIKE  SY-DATUM.
          UNIX_COMMAND  = 'Z_HR_FILE_TRANSFER'.
          FILENAME1 = '/US/hrit-sdck/trsf0019.toc'.
          FILENAME2 = '/test/esc/inbound/done'.
          DEST = 'cib10'.
          CONCATENATE FILENAME1 FILENAME2 INTO PARAMS SEPARATED BY SPACE.
          CALL FUNCTION 'SXPG_COMMAND_EXECUTE'
          EXPORTING
            commandname                   = unix_command
            destination                   = dest
            additional_parameters         = params
          IMPORTING
            status                        = return_code
          TABLES
            exec_protocol                 = tabl
          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.
        IF return_code NE 'O'.
           WRITE:/ 'UNIX status UNSUCCESSFUL TRANSFER RETURN CODE = ',return_code.
        ENDIF.

    Script qui copie un fichier en utilisant le protocole ssh
    Parametres Obligatoire:
          $INTERFACE => Interface
          $SOURCESID => SID d'origine
          $TARGETSID => SID de destination
          $AREA      => Area
          $LOCAL_AREA      => Nom de repertoire qui doit figurer dans le path de source entre "interfaces" et "outbound".
          $FILENAME  => Filename (Could contain a wild card)
          $LOCATION  => Nom de repertoire qui doit figurer dans le path de destination entre "$TARGETSID" et "common"
          $DIRECTION => inbound/outbound

  • SXPG_COMMAND_EXECUTE issue

    Hello Experts,
    We have this issue in client server.One of the batch job is frequently failing while executing this function module SXPG_COMMAND_EXECUTE with error as command_not_found.This error occurs frequently on a particular application server but not all the times it fails but we find some job failures 2 to 3 times a day,as this batch job is running every 15min.Please find the sample code below and advice.Many thanks in advance.
      CALL FUNCTION 'SXPG_COMMAND_EXECUTE'
           EXPORTING
                commandname                   = 'ZZ_YP_MKDIR'
                additional_parameters         = w_command
           TABLES
                exec_protocol                 = i_command_results
           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 = 0.
        LOOP AT i_command_results.
          WRITE: / i_command_results-length,
                   i_command_results-message.
          IF i_command_results-message <> space.
            w_error = 'X'.                                      "AN14112002
            MESSAGE i179(zv) WITH i_command_results-message
                                  v_char_seqno.
            "'Make Directory failed'
          ENDIF.

    Hi swathv     
    That function is used for calling Unix scripts on the application server,
    You can specify a unix script as a command on transaction SM69
    and than you can call this command with function 'SXPG_COMMAND_EXECUTE'
    Can you find this command in SM69 and related script,
    and learn what is it used for?
    Maybe you are using more than 1 application server,
    and script file exist on a server but doesn't exist on other.
    I hope it helps.

  • SXPG_COMMAND_EXECUTE in background

    Hi all.
    Does the FM SXPG_COMMAND_EXECUTE can be activated within background mode?
    When I activate the abap program that includes the above FM within a periodic job it's not being executed.
    Any reason for that?
    Thanks in advance,
    Rebeka

    *--> Activate decryption command
        CALL FUNCTION 'SXPG_COMMAND_EXECUTE' "IN BACKGROUND TASK
          EXPORTING
            COMMANDNAME                   = 'ZFI_GPG'
            ADDITIONAL_PARAMETERS         = LV_PARAMS
            OPERATINGSYSTEM               = 'Windows NT'
            TARGETSYSTEM                  = LV_SERVER
          IMPORTING
            STATUS                        = STATUS
            EXITCODE                      = EXITCODE
          TABLES
            EXEC_PROTOCOL                 = LT_PROT_TAB
          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.
    When 'ZFI_GPG' is the command from sm69 and lv_params is the additional parameters.
    Thanks a lot,
    Rebeka

  • SXPG_COMMAND_EXECUTE - returns an error

    Hi All,
    I am using the FM SXPG_COMMAND_EXECUTE to run a unix script which fetches a pdf file written from ABAP code into
    application server.
    I have written the pdf file, and while run separately the Unix script is working fine.
    But the FM which calls the unix script, SXPG_COMMAND_EXECUTE, returns errors which say that the pdf file could not be opened. I have written the pdf file in binary form on the application server.
    Please help.
    This is my code:
    CALL FUNCTION 'CONVERT_OTF'
        EXPORTING
          format                = 'PDF'
          max_linewidth         = 132
        IMPORTING
          bin_filesize          = gv_bin_filesize
          bin_file              = gt_bin
        TABLES
          otf                   = gt_otf
          lines                 = gt_pdf_tab
        EXCEPTIONS
          err_max_linewidth     = 1
          err_format            = 2
          err_conv_not_possible = 3
          OTHERS                = 4.
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
        WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.
      data:    mstr_print_parms LIKE pri_params,
               gv_file type string value '/usr/sap/ABAP-TMP/',
               wa_pdf_tab like line of gt_pdf_tab,
               it_docs TYPE STANDARD TABLE OF docs,
               it_lines TYPE STANDARD TABLE OF tline,
               gv_frontfile type string ,
               wa_lines type tline.
    concatenate gv_file wa_final-pernr '.pdf' into gv_file.
    open dataset gv_file for output in binary mode.
    transfer gt_bin to gv_file.
    close dataset gv_file.
    CONSTANTS: c_extcom    TYPE sxpgcolist-name VALUE 'ZHRPAYSLIP',
               c_oper      TYPE syopsys VALUE 'Linux'.
    DATA: v_dir_input      TYPE sxpgcolist-parameters.  " Input Directory
    DATA: t_result         TYPE STANDARD TABLE OF btcxpm.
    concatenate wa_final-pernr
                gs_reclist-receiver
                '93210951'
                into v_dir_input
                separated by space.
    CALL FUNCTION 'SXPG_COMMAND_EXECUTE'
      EXPORTING
        commandname                   = c_extcom
        additional_parameters         = v_dir_input
        operatingsystem               = c_oper
      TABLES
        exec_protocol                 = t_result
      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.
    Thanks,
    Anita

    Hi guys,
    Issue has been resolved. I was writing the pdf file in the application server, wheras the Unix script had some other directory as its present working directory.
    As we are using the same directory for the purpose, this directory and folder name was hard coded in the Unix script as well,
    so that the confusion of path is resolved.
    Thus this issue was resolved from the Unix script itself.
    Thanks.
    Anita Jeyan.

  • SXPG_COMMAND_EXECUTE Can't exec external program (No such file or directory

    Hi Experts,
    I need to launch or terminate an external application (i.e. command prompt, notepad, etc.) in background job by using FM SXPG_COMMAND_EXECUTE. However, I am unable to proceed because of the following error occured after executing the command in SM69.
    Can't exec external program (No such file or directory)
    External program terminated with exit code 1
    I was using the following sample code. Can someone tell me what might be the cause of the problem?
    DATA: lv_status TYPE extcmdexex-status,
          lt_output TYPE TABLE OF btcxpm,
          lv_opsys  TYPE sy-opsys.
    lv_opsys = 'WINDOWS NT'.
    CALL FUNCTION 'SXPG_COMMAND_EXECUTE'
      EXPORTING
        commandname                   = 'ZIEXPLORE'
        additional_parameters         = '/c'
        operatingsystem               = lv_opsys
      IMPORTING
        status                        = lv_status
      TABLES
        exec_protocol                 = lt_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.
    ZIEXPLORE command
    Operating system command: cmd
    Parameters for operating system command: taskkill /f /im iexplore.exe
    Thanks and Regards,
    Louie

    Hi Louie,
    I am not able to assume the reason of the problem, If you say that its not getting executed in SM49 then the problem lies there.
    So I am providing you a link which might be helpful, just go through it and cross check. There is a parameter called "trace" in the fm mentioned.
    Secton Microsoft Windows NT - [Prerequisites for Running External Commands and External Programs|http://help.sap.com/saphelp_nw70/helpdata/en/c4/3a7fbb505211d189550000e829fbbd/content.htm]
    [Analyzing Problems with External Commands and Programs|http://help.sap.com/saphelp_nw70/helpdata/en/c4/3a80c4505211d189550000e829fbbd/content.htm]
    May be you can post this question in [SAP AS General|SAP NetWeaver Application Server; also.

  • FUNCTION SXPG_COMMAND_EXECUTE External program terminated with exit code 2

    HI,
    I am using the below Function Module
    gv_ap = '/nfs/ficheiros/FicheiroExtraccaoSIF/outbox'
    CALL FUNCTION 'SXPG_COMMAND_EXECUTE'                 
          EXPORTING                                       
               commandname                   = 'Z_LS'     
               additional_parameters         = gv_ap      
          TABLES                                          
               exec_protocol                 = t_fich     
          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.        
    with this folder '/nfs/ficheiros/FicheiroExtraccaoSIF/outbox' return the error:
    /nfs/ficheiros/FicheiroExtraccaoSIF/outbox not found and
    External program terminated with exit code 2
    but if i map other directory the function return the files and folders that directory have.
    Anyone could help me.
    Thanks and Regards.
    Eduardo Paiva

    Hi,
    Yes i have read access to this directory and the command 'Z_LS' exists.
    Best Regards,
    Eduardo Paiva

  • SXPG_COMMAND_EXECUTE - need help

    Hello Friends,
    Please explain me the functionality of this program.
    REPORT ZABC.
    PARAMETER PCOMMAND(18) DEFAULT 'zw1001'.
    DATA: BEGIN  OF PROTOCOL OCCURS 0.
            INCLUDE STRUCTURE BTCXPM.
    DATA: END OF PROTOCOL.
    DATA:  STATUS_00 LIKE  BTCXP3-EXITSTAT.
    DATA: XCOMMAND LIKE SXPGCOTABE-NAME.
    DATA: ADDI_PARA LIKE SXPGCOLIST-PARAMETERS.
       MOVE PCOMMAND TO XCOMMAND.
       CLEAR   STATUS_00.
       CALL FUNCTION 'SXPG_COMMAND_EXECUTE'
            EXPORTING
                 COMMANDNAME                   = XCOMMAND
            IMPORTING
                 STATUS                        = STATUS_00
            TABLES
                 EXEC_PROTOCOL                 = PROTOCOL
            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.
    WRITE: / SY-SUBRC.
    WRITE: / STATUS_00.
    LOOP AT PROTOCOL.
       WRITE: / PROTOCOL.
    ENDLOOP.
    Thanks,
    Shreekant

    Using this function module, you can check the authorization of a user to 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 command stored in the database, then the value of this parameter is substituted into the command. If an SAP application server is active on the target system (TARGETSYSTEM), then the profile parameter values are read from the profile that is active on that system. No parameter substitution is made 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 command definition, this function module is also called in the course of processingebenfalls. This function module can prevent execution of the command.
    If the authorization checks complete successfully, the command is run on the target host system.

  • Dump while SXPG_COMMAND_EXECUTE

    Hi Experts,
    While i am calling SXPG_COMMAND_EXECUTE in my program, the system is going to dump as i have no permissions for unix. I placed a message after
    if sy-subrc <> 0.
    MESSAGE e000(msgclass) with 'No permissions'.
    endif.
    but it displays the above message and then still goes to dump .
    I want to avoid the dump  pls tell me how to handle this.
    thanks
    Dany

    Hi,
    Yes  i had specified all the exceptions.
    pls have a look below after if sy-subrc <> 0.
       CALL FUNCTION 'SXPG_COMMAND_EXECUTE'
        EXPORTING
          commandname                         = zip_commnd
         additional_parameters               = allinv
      operatingsystem                     = 'UNIX'
      TARGETSYSTEM                        = SY-HOST
      DESTINATION                         =
      STDOUT                              = 'X'
      STDERR                              = 'X'
      TERMINATIONWAIT                     = 'X'
      TRACE                               =
    IMPORTING
      STATUS                              =
      EXITCODE                            =
        TABLES
          exec_protocol                       = t_billdir
       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 <> 0.
       MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
               WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    MESSAGE e000(msgclass) with 'No permissions'.
      ENDIF.
    is that right?
    thanks
    Dany

Maybe you are looking for

  • Help with Gimics

    Thank you for all your recent help with this project I am now taking a different approch with the visuals just a little extra to go with th enew fuctionality. I have just added the code from the update content sample this work fine but only on the fi

  • Start Up Screen / Automatic Camera

    Hi When I press the on button to wake my LUMIA 520 up, the start up screen is brielfy visible before the camera then automatically start itself up, and I dont even get chance the slide/swipe the screen up?! I have had the phone for a while and its on

  • *HELP* My Macbook Retina (2013) shuts down immediately after login.

    When the computer is off, I press the power buttom and the normal white apple logo comes onto the black screen.  It prompts me to login, which I do.  Then under my username and avatar, a grey progress bar appears (the background is not grey, it is a

  • Creating Transport rule : Exception has been thrown by the target of an invocation.

    hi, I'm trying to create a new transport rule and get the error Test Auto-reply Failed Error: Exception has been thrown by the target of an invocation. Exchange Management Shell command attempted: New-TransportRule -Name 'Test Auto-reply' -Comments '

  • Updating iOS at work?

    I brought my laptop to work today to update my iPhone (no iTunes on my work computer) but out wi-fi isn't working. Is there a way I can download the update as a data file on one computer and transfer it to my laptop? I know there are those IPSW files