FM-----SXPG_CALL_SYSTEM

what this fm do.
and what is "commandname"--is he running batch file???

check the documentation of the FM in SE37...
FU SXPG_CALL_SYSTEM
Text
     Execute an External Command
Functionality
     SXPG_CALL_SYSTEM: Execute External Command (Express Method)
     Using this function module, you can:
     o   Check a user's authorization to execute a command
     o   Execute the command
     To determine the system on which the command should be executed, the
     function module uses by default the current host system and the current
     operating 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 a
     different SAP application server. The external command is then
     accordingly executed in the host system of the other SAP server.
     SXPG_CALL_SYSTEM uses the following rules to determine which variant of
     a command is used for the execution:
     o   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
         execution of the command.
     o   If the first check fails, the syntax group for SY-OPSYS is        determined. A syntax group is an SAP construct that groups operating
       systems that use the same syntax for commands and filenames. If a
       command whose operating system type matches the determined syntax
       group, this definition of the command is used.
   o   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 is then used, if found.
   o   Otherwise, the exception COMMAND_NOT_FOUND is triggered.
se
Syntax:
   CALL FUNCTION SXPG_CALL_SYSTEM
        IMPORTING
           COMMANDNAME   = <SAP command name>   DEFAULT '*'
           ADDITIONAL_PARAMETERS    = <Argument string> default <space>
        EXPORTING
           STATUS        = <Exit status of command>
         TABLES
           EXEC_PROTOCOL = <Log>   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 additional security
   check
           PROGRAM_START_ERROR  Error while starting program

Similar Messages

  • SXPG_CALL_SYSTEM performance question

    Hi all,
    I'm using FM <b>SXPG_CALL_SYSTEM</b> in order to execute a server command which grants permissions to a file (just executes <u>CHMOD 777</u>). (also tried with <b>SXPG_COMMAND_EXECUTE</b>)
    My problem is regarding performance in this FM (program is executed in background, and there are lots of files)
    Does anybody knows any other way of giving such privileges to a file?
    Thanks in advance.

    Finally, performance problem is not due to this FM but server script executed.
    Thanks

  • How to use FM: SXPG_CALL_SYSTEM

    Hi all.
    i used the FM SXPG_CALL_SYSTEM  as below
    w_ext_cmd = 'ZREMSH'.
    w_params = 'HARP -L BATCHMGR LS -L ~ORDER_BOOKING/PMAIL/DV4/*.TXT'.
    CALL FUNCTION 'SXPG_CALL_SYSTEM'
          EXPORTING
            commandname                = w_ext_cmd
            additional_parameters      = w_params
    ZHREMSH was already added by BASIS.
    the output was ERROR:
                          18  permission denied.
                          44  External program terminated with exit code 1
    i loggen in into my user Account.
    can u please provide me the process how i can execute it successfully. If possible with a sample program.
    thanks,
    Ajay

    Hi Ajay,
    Refer below code snippet :
    DATA: DIR_PREFIX(40) TYPE C VALUE '/usr/sap/trans/SID/BACCHUS',
            FROM_FILE(125) TYPE C,
            TO_FILE(125) TYPE C,
            W_MESS_AREA LIKE TSL1D-AREA VALUE 'LC',
            W_MESS_AREA_SUB LIKE TSL1D-SUBID VALUE '0',
            W_CMD    LIKE SXPGCOLIST-NAME,           "cmd name
            W_STATUS LIKE BTCXP3-EXITSTAT, "cmd exit status
            W_PARM   LIKE SXPGCOLIST-PARAMETERS.           "cmd parameters
      DATA:  RTAB LIKE BTCXPM OCCURS 20 WITH HEADER LINE.
    * Logical command name
      MOVE: COMMAND TO W_CMD,
            IN_FILE TO FROM_FILE,
            OUT_FILE TO TO_FILE.
    * Check directory prefix
      REPLACE 'SID' WITH SY-SYSID INTO DIR_PREFIX.
      CONDENSE DIR_PREFIX NO-GAPS.
      IF FROM_FILE(24) NE DIR_PREFIX(24) OR
           TO_FILE(24) NE DIR_PREFIX(24).
        MESSAGE ID 'ZBCSTANDARD' TYPE 'E' NUMBER 107 WITH FROM_FILE(24).
      ENDIF.
      CONCATENATE FROM_FILE
                  TO_FILE
                  INTO
                  W_PARM
                  SEPARATED BY SPACE.
      CALL FUNCTION 'SXPG_CALL_SYSTEM'
           EXPORTING
                COMMANDNAME                = W_CMD
                ADDITIONAL_PARAMETERS      = W_PARM
           IMPORTING
                STATUS                     = W_STATUS
    *           EXITCODE                   =
           TABLES
                EXEC_PROTOCOL              = RTAB
           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
                OTHERS                     = 12.
      IF SY-SUBRC NE 0.
        IF SY-SUBRC EQ 4.
          MESSAGE ID 'ZBCSTANDARD' TYPE 'E' NUMBER 105 WITH SY-SUBRC
                                                            FROM_FILE.
        ELSE.
          MESSAGE ID 'ZBCSTANDARD' TYPE 'E' NUMBER 106 WITH SY-SUBRC
                                                            TO_FILE.
        ENDIF.
      ELSE.
        IF W_STATUS EQ 'O'.
    *     Command executed
          READ TABLE RTAB INDEX 1.
          IF RTAB-MESSAGE CO '1234567890 '.
          ELSE.
    *       Executed command came back with an error
            MESSAGE ID 'ZBCSTANDARD' TYPE 'E' NUMBER 108 WITH RTAB-MESSAGE.
          ENDIF.
        ELSE.
    *     Command not executed
    *     MESSAGE ID 'ZBCSTANDARD' TYPE 'E' NUMBER 109 WITH w_status
    *                                                       to_file.
        ENDIF.
      ENDIF.
    ENDFORM.                               " MOVE_FILE
    Regards
    Abhii

  • SXPG_CALL_SYSTEM- Damage at OS Level any other alternate

    Hi Team,
    I have requirement to archive files to encrypt the file I am using FM-SXPG_CALL_SYSTEM but I came to know that if we use it there will be a lot of damage at OS Level.Is there any other cleaner way to do the same.
    Please help me.
    Thanks and Regards,
    Shakeer Hussain

    You better use FM 'SXPG_COMMAND_EXECUTE' instead of SXPG_CALL_SYSTEM.
    I remember Sandra Rossi highlighting a few of them but don't think any of the differences stated that the latter would damage the OS while the former wouldn't. If you run a malicious system command both the FMs will give you the same end result.
    @OP:
    I came to know that if we use it there will be a lot of damage at OS Level.
    Where do you get such information from? I have used external OS commands(non-malicious ones, of course) and none of them have given me any problem.
    - Suhas

  • Copy command called through FM SXPG_CALL_SYSTEM not performed properly

    Hi  Gurus,
    I am calling the FM SXPG_CALL_SYSTEM with the command name as COPY maintained for windows NT server and I am passing the additional parameters with the file names ( source file <space> destination file). Source files can be picked using wild characters (for eg:filename_o_*.wrk) and all the files fetched from Source has to be placed into the one target file specified in the destination.
    While performing this FM, we are getting error sometimes. suppose if there are two files present in the source, first part of first file and second part of second file is copied and not the whole file. So we are missing second part of first file and first part of second file. This happens randomly like once in a day. Can you please suggest how to rectify this error?
    This is in High priority.  Any immediate response is highly appreciated.
    Please advice me the right forum for posting this if this is not the right forum.

    Thx for the explanation, you're right! (very surprising to me)
    Well, I tried on my XP SP 3 system:
    When we use * or ?, then there's the issue you mention:
    - For the test, I created 2 files named source1 and source2, one containing AAAA\[CTRLZ\]BBBB in my local encoding (cp1252), and the other CCCC\[CTRLZ\]DDDD.
    - If I use COPY source* result, a new file "result" is created containing AAAACCCC\[CTRLZ\]. Note that \[CTRLZ\] is always added once at the end.
    - If I do it with only one file but with a generic character (COPY sourc?1 result), there's the same issue.
    - Same issue also if I copy a whole directory to a file (COPY directory result)
    When I use COPY source1 result (only one source file, and no generic character * or ?), there's no issue.
    When I use /b (COPY /b source* result), it works well. Note: be careful with /b position, COPY source* result /b, /b is ignored if it is at the end.
    Doesn't explain why the beginning of a file was not copied, though.

  • Using SXPG_CALL_SYSTEM  to execute Unix 'MV' command not working

    Here is the code (method - params begin with "p_").  This returns no error but yet the file is not moved (called in a test program).  Any ideas?
    DATA: lv_sourcepath TYPE rlgrap-filename,
            lv_targetpath TYPE string,
            lv_fname      TYPE rlgrap-filename,
            lv_path       TYPE rlgrap-filename,
            lv_paramstr   TYPE sxpgcolist-parameters,
            lv_status     TYPE extcmdexex-status,
            lv_execproto  TYPE TABLE OF btcxpm.
      " Get physical path to archive folder
      lv_targetpath = zcacl001_utilities=>get_appserver_path( 'ZDIR_KHRIS_INTF_ARCV' ).
      " Type casting needed for function module call below
      lv_sourcepath = p_sourcepath_in.
      " Split filename from path in source
      zcacl001_utilities=>parse_file_path( EXPORTING
                                              p_fullname_in   = lv_sourcepath
                                           IMPORTING
                                              p_filename_out  = lv_fname
                                              p_path_out      = lv_path ).
      " Concatenate filename to target path
      CONCATENATE lv_targetpath lv_fname INTO lv_targetpath.
      " Build parameter string
      CONCATENATE '-f' lv_sourcepath lv_targetpath INTO lv_paramstr SEPARATED BY space.
      CALL FUNCTION 'SXPG_CALL_SYSTEM'
        EXPORTING
          commandname                = 'mv'
          additional_parameters      = lv_paramstr
          trace                      = space
        IMPORTING
          status                     = lv_status
          exitcode                   = p_exitcode_out
        TABLES
          exec_protocol              = lv_execproto
        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
          parameter_expected         = 8
          too_many_parameters            = 9
          illegal_command                = 10.

    Try to put this type of entry in the Object request.
    Prog Obje Objectname
    R3TR EXCC commandname
    I am not sure, weather this will work or not.
    Regards,
    Naimesh Patel

  • Wildcard in rm with SXPG_CALL_SYSTEM

    Hello everyone
    I'm calling function SXPG_CALL_SYSTEM for a system command without parameters.
    This command is defined in sm69 and is stated:
    command: rm
    parameters: -r /Gedis/Interfaces/GD1/DOC1/tre/*
    extra parameters: no.
    The function executes and the result i get is: 
    rm: /Gedis/Interfaces/GD1/DOC1/tre/*: A file or directory in the path name does not exist.
    We double- and  triplechecked the writing, and that's ok.
    Could it be that the wildcard '*' can not be executed ?
    Thanks in advance.
    Merijn.

    Well even i tried once for executing a wild card search parameter for a call to an external global data system for fetching vendor details through SXPG_CALL_SYSTEM. And we convinced the client that it was not possible and changed the bussiness requirement. Lets wait and see if someone comes up with a solution if it exists.
    Virkanth

  • SXPG_CALL_SYSTEM fails giving NO PERMISSION

    Hi!
    I am trying to work with the SXPG_CALL_SYSTEM and executing UNIX commands that have been defined in the SAP Standard table SXPGCOTABE.
    I get the exception NO PERMISSION while working with the above FM in one of the SAP instances, while in the other SAP instance everything works well.
    Any idea as to what could be the root cause behind it.
    Please respond.
    Thanks.

    Hi Shyam,
    There could be couple of reasons you are getting that error. Either you dont have permissions at unix level tto perform some specific operations or your unix script might be trying to write some file or backup some file which may not have full write permission.
    Login to Unix system and check the write access of the file or the permissions you have. this Will give you some pointers. Hope this helps
    Cheers
    VJ

  • 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

  • SXPG_CALL_SYSTEM execution

    Hello everybody
    I need some help with SXPG_CALL_SYSTEM.
    I use it to in combination with unix commands TAR en GZIP.
    Everything works when i'm logged in as an admin user.
    The problem is that the commands don't do a thing when i'm logged in as a normal user.
    The return code of the function is 0, so it  means the command is executed. But it hasn't done anything.
    But i would like to get the 'no permission' exception (or any other) to verify that the commands aren't executed.
    Is there anyway to check if the user can execute this function.
    Thx in advance.
    Merijn.

    The function module [SXPG_CALL_SYSTEM|http://help.sap.com/saphelp_nw70/helpdata/en/fa/0971ee543b11d1898e0000e8322d00/frameset.htm] should already execute an authorization check. When you mention a return code 0 I'm assuming that you are talking about SY-SUBRC in ABAP (not OS level) and that you are not doing something obvious like setting all exceptions to 0 (e.g. OTHERS = 0)...
    There's function module [SXPG_COMMAND_CHECK|http://help.sap.com/saphelp_nw70/helpdata/en/fa/097208543b11d1898e0000e8322d00/frameset.htm], which can be used just for carrying out the authorization check.
    I suspect your normal user doesn't have authorization for SM49, but I'd give this a try and see what happens. Also, you might want to check the system log (SM21) and the trace file dev_cp (ST11, depending on your patch level you might need to activate trace via setting the TRACE parameter) and see if that gives you anything useful. In addition you could of course also try an authorization trace (ST01).
    That's pretty much all I can think of right now. Maybe somebody else has some better ideas or you have some further details after doing some more checks...

  • SXPG_CALL_SYSTEM Error!!

    Hi experts,
    I have created a command ZMKDIR in SM69,
    And i am trying to access it using FM SXPG_CALL_SYSTEM.
    Now for some users, i get the NO_AUTHORISATION error.
    How is it possible to make it work for all users.
    I mean is there a way to bypass the user authorisation check?
    Brgds,
    K

    Contact your BASIS team and ask them to change the authorization according to your requirement.
    regards,
    Padma

  • About function :SXPG_CALL_SYSTEM

    hi,dear all:
         I want to call an external program of a windonws 2003 system using  function SXPG_CALL_SYSTEM,can you give me some advice,notes or give me some example about it?

    Jian,
    check the documentation of the FM in SE37...
    FU SXPG_CALL_SYSTEM
    Text
    Execute an External Command
    Functionality
    SXPG_CALL_SYSTEM: Execute External Command (Express Method)
    Using this function module, you can:
    o Check a user's authorization to execute a command
    o Execute the command
    To determine the system on which the command should be executed, the
    function module uses by default the current host system and the current
    operating 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 a
    different SAP application server. The external command is then
    accordingly executed in the host system of the other SAP server.
    SXPG_CALL_SYSTEM uses the following rules to determine which variant of
    a command is used for the execution:
    o 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
    execution of the command.
    o If the first check fails, the syntax group for SY-OPSYS is determined. A syntax group is an SAP construct that groups operating
    systems that use the same syntax for commands and filenames. If a
    command whose operating system type matches the determined syntax
    group, this definition of the command is used.
    o 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 is then used, if found.
    o Otherwise, the exception COMMAND_NOT_FOUND is triggered.
    se
    Syntax:
    CALL FUNCTION SXPG_CALL_SYSTEM
    IMPORTING
    COMMANDNAME = <SAP command name> DEFAULT '*'
    ADDITIONAL_PARAMETERS = <Argument string> default <space>
    EXPORTING
    STATUS = <Exit status of command>
    TABLES
    EXEC_PROTOCOL = <Log> 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 additional security
    check
    PROGRAM_START_ERROR Error while starting program
    ==============
    This command can be edited in Tx SM69 and executed in Tx SM49. Just have a look in one of these transactions
    http://help.sap.com/saphelp_nw04/helpdata/en/fa/0971ee543b11d1898e0000e8322d00/content.htm
    look here : Re: Rename a file
    Don't forget to reward if useful....

  • Parameters of SXPG_CALL_SYSTEM

    Hi,
    SXPG_CALL_SYSTEM has two importing parameters, status and exitcode.
    status is describes in the documentation, whereas exitcode is not.
    Is it sufficient to check status and sy-subrc for successful execution? What does exitcode contain?

    Hi,
    I guess it is the exitcode that is returned from the called program or script.
    static int Main(string[] arguments)
                //return exit code
                // 0  : case 0
                // 1  : case 1
                // 2  : case 2
                // -1 : error occured
                return exitCode;
    /Simo

  • How to  add a folder in unix directory?

    how to  add a folder in unix directory?
    /usr/zz00/zz/mm/..
    i need one more folder
    /usr/zz00/zz/mm/addfolder/text.txt..

    No way with pure ABAP. Either contact your unix adminstration or create a logical system command in SM69/SM49 which can be called via call function 'SXPG_CALL_SYSTEM'

  • Creating a folder in application server in background.

    Hi experts,
    Is it possible to Creating a folder in application server in background.?
    My requirement is like this , every time a PO is created it has to be saved locally.
    When atlast i manged to do this, i get stuck again by this CR ,
    The PO has to be saved in a folder with the same name as PO number,
    I do not know if it is possible.
    So as always I am looking for inputs/suggestions or knowledge if you had come across scenario like this one.
    Thanks and Regards,
    K

    Hi,
    You could create a system command in SM69 to create a directory and then use the function module SXPG_CALL_SYSTEM to invoke the command and pass in the directory name as a parameter at run time.
    Darren

Maybe you are looking for

  • Creative Cloud is blank - I can't use it!

    I've just got my laptop back(windows 8.1 operating system) after repairs and the creative cloud desktop app that was on there now isn't, so no problem; i go to download it but when it's finished downloading and it opens i am confronted by a blank scr

  • Photos on iPhone in wrong order after sync with iMac iPhoto

    I just purchased my iPhone 6 and am trying to get it all set up with my photos stored on iPhoto on iMac. When I sync phone using iTunes all of images sync over. Not a problem. But here's where the issue is... On my iMac in iPhoto, all photos are disp

  • PO & GR number range...

    Hi all, Is it possible to have number range for PO at plant level. Is there any user exit available. Similarly, is there any user exit avalable for number range at plant level material type wise for GR & GI documents please. Thanks.

  • BDC for creating sales order

    Hi, can anyone give me any <a href="http://theblogwhichsaysall.blogspot.com">hint</a>

  • Variant Configurator--Extractor

    Hi, we have sales order and associated variant configuratorin R3  that contains Material features, options and its associated components. Is there a standard extractor to extract the associated details from variant configurator. I read through SDN an