This website is not affiliated with, sponsored by, or approved by SAP AG.

execute OS command on the server

Development (ABAP Development WorkBench, ABAP/4 programming)

Moderators: Snowy, thx4allthefish, YuriT, Gothmog

execute OS command on the server

Postby Guest » Thu Jul 31, 2003 1:52 am

Hi,
is there any FM, which executes command on the Server OS? I know about 'WS_EXECUTE', but it is used to execute command on the front-end OS.

Thank you
Guest
 

Postby Rich » Thu Jul 31, 2003 4:30 am

You have to use function module SXPG_COMMAND_EXECUTE in conjunction with transactions SM69 and SM49.

You define your command in SM69 (if it's a standard command then it might already be there) and then call it via the above function module. If not you define the command and the operating system it's applicable to.

This enables commands with the same name but different operating systems to be constructed so that the ABAP code does not have to be altered for each individual operating system.

Regards

Rich
Regards

Rich

Image
Abap KC:http://www.richard-harper.me.uk/Kb
SFMDR:http://www.se37.com
Rich
 
Posts: 7112
Joined: Thu Oct 31, 2002 4:47 pm
Location: Liverpool

Postby Guest » Thu Jul 31, 2003 8:23 am

Hi Rich,
thank you for your reply. I want to execute BAT file and therefore I created command ZBAT with command line - cmd c:\file.bat
Unfortunatelly it wasn't executed. :(
Made I something wrong?
Guest
 

Postby grappatax » Fri Aug 01, 2003 8:37 am

Hi,
try to create a command with:
Operating system command = 'cmd /c'
Parameters... = your command (in this case c:\file.bat)

I have this solution on a WIN server. It's works fine!
:wink:
Grappatax

P.S. The solution is to add '/c', but if you create a command as I done you will be able to reuse it for all commands you need! :D
grappatax
 
Posts: 6
Joined: Wed Jul 30, 2003 4:04 am
Location: Italy

Postby Rich » Mon Aug 04, 2003 3:40 am

Anonymous wrote:Hi Rich,
thank you for your reply. I want to execute BAT file and therefore I created command ZBAT with command line - cmd c:\file.bat
Unfortunatelly it wasn't executed. :(
Made I something wrong?


One of the main reasons why things are not executed is permissions.

Check that you have the relevant authorisations to use SXPG_COMMAND_EXECUTE, and that the SAP user has execute permission in the relevant directory.

Rich
Regards

Rich

Image
Abap KC:http://www.richard-harper.me.uk/Kb
SFMDR:http://www.se37.com
Rich
 
Posts: 7112
Joined: Thu Oct 31, 2002 4:47 pm
Location: Liverpool


Return to ABAP

Who is online

Users browsing this forum: No registered users and 12 guests





This website is not affiliated with, sponsored by, or approved by SAP AG.