Skip to Content
External Operating System Commands

In many instances a developer may need to execute an operating system command to achieve the specific requirements of the application. The transaction SM69 can be used to create / maintain external operating system commands. These commands are protected by SAP system authorizations and provide the safest way of executing OS commands from an SAP Web AS system.

The snapshot below shows the parameters required during the creation of an external OS command. This sample external command is used to move a file in the application server from one directory to another.


Using External Commands in an ABAP Program

Use the function module ‘SXPG_COMMAND_EXECUTE’ to execute an external command in an ABAP program. See sample code for details:

Additional Authorization Checks through Check Module

When you create an external command, you can specify an additional function module which will be called to check a user’s authorization to run a command. The function module should have the interface of SXPG_DUMMY_COMMAND_CHECK.


To write your own authorization-checking module, do the following:

1. Create a function module, say ZMOVE_COMMAND_CHECK, as a copy of SXPG_DUMMY_COMMAND_CHECK
2. Write your code for authorization check.
3. Specify the function module as Check module in SM69.

To report this post you need to login first.


You must be Logged on to comment or reply to a post.

    1. Nigel James
      It’s nicely written, it has some great screenshots, it may well be easier to find than content on help (which has its own challenges) and it’s his first blog. Given that it is his first blog it will have to have been approved by the moderators, so they must have thought it was worthy.

      Cut him some slack and let him play himself into a great SDN innings. Writing a blog that has the potential to be seen by 600 000 people can be a little daunting, let alone navigating the wonders of the SDN blogging interface.

      Welcome to the world of SDN blogging, TK. I look forward to your next blog.



    2. Former Member Post author
      Hi Eddy,

      Though SAP has provided a comprehensive documentation on the subject, most of the developers are not making use of this feature. They tend to use UNIX shell scripts and some other mechanisms to achieve the functionality. So, I thought of giving a very crisp documentation, with a sample code, which will help them to use the standard feature.

      Sameej T.K.

  1. Former Member
    Now suppose I have created a executable namely xyz.exe.

    Now i create a operating system command for it to execute. It says file not found when i execute it. I guess I have to put it in some specific directory..???

    Btw I created command for Windows NT.

  2. Former Member
    I had an error 2 with this code and I corrected it by adding

    OPERATINGSYSTEM               = ‘UNIX’

    in the exporting parameters of SXPG_COMMAND_EXECUTE.

    maybe it will help people to know about it ๐Ÿ™‚

    1. Former Member Post author
      By default, the function module takes SY-OPSYS as the operating system. This should work fine. A wide guess on why it didn’t work for you – the Operating System parameter in SM69 command doesn’t match with SY-OPSYS.
      Eg. SY-OPSYS = “HP-UX”, but you have given Operating System = “UNIX” while creating external OS command in SM69.


  3. Former Member
    Created a Executable Command in sm69 to create new directory.

    When i run the FM SXPG_COMMAND_EXECUTE in the UNIX it creates directory.

    In the Window NT System return a error
    “Can’t exec external program (No such file or directory)                                       WaitForSingleObject failedwith %d (No such device or address)”

    Does this FM work for Window NT ?
    I appriciate your help.

    1. Former Member Post author
      Ofcourse the FM will work in Windows NT. I have few questions :

      1. Does the command you have specified in SM69  recognized at OS level ?
      2. The parameters you pass to the the command are valid ?
      3. Are you able to execute the command in SM49 ?


      1. Former Member
        Thank you Sameej for your reply,

        I want to create directory in a specified folder.
        The command for Windows NT is “cmd” .

        So in sm49 a have
        Operating system command: cmd
        Additional parameters: C:\tmp\test
        When i execute it i have the message:
        Microsoft Windows[Version5.2.3790]                                (C) Copyright 1985-2003 Microsoft Corp.

        Also when i run the FM SXPG_COMMAND_EXECUTE i have sometime the above message and when i run it again the exception: COMMAND_NOT_FOUND

        As a result i cannot see any folder “test”.
        I dont know what is wrong.




Leave a Reply