Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

How can I a external command from OS?

Former Member
0 Likes
1,265

Hello expert,

How can I a external command from OS level? I do not mean FM GUI_EXEC which can only execute the commond from my local laptop.

the FM i am looking for should execute the file from D:\usr\sap\ABC\sys\....to restart the SAP system from OS level like it did in SM49.

Best regards,

Cliff

Hello expert,

How can I a external command from OS level? I do not mean FM GUI_EXEC which can only execute the commond from my local laptop.

the FM i am looking for should execute the file from D:\usr\sap\ABC\sys\....to restart the SAP system from OS level like it did in SM49.

Best regards,

Cliff

8 REPLIES 8
Read only

Former Member
0 Likes
1,220

Hi,

Try with this RFC SXPG_COMMAND_EXECUTE. using this you can execute external commands in a external OS

Regards,

Vikranth

Read only

0 Likes
1,220

HI Vikranth,

I am using that. however It raise an error that my restart.bat can not be found..

CALL FUNCTION 'SXPG_COMMAND_EXECUTE'

EXPORTING

COMMANDNAME = 'd:\restart.bat' .

Many thanks.

Read only

0 Likes
1,220
CALL METHOD cl_gui_frontend_services=>execute
  EXPORTING
    application            = 'C:\somu.bat'.
Read only

0 Likes
1,220

Hi,

SXPG_COMMAND_EXECUTE is only used when you want to execute a command on a external OS like a different UNIX server. If you are trying to exexute the file in the local presentation server use cl_gui_frontend_services=>execute as suggested.


CALL METHOD CL_GUI_FRONTEND_SERVICES=>EXECUTE
  EXPORTING
    APPLICATION               = 'd:\restart.bat'
  EXCEPTIONS
    CNTL_ERROR             = 1
    ERROR_NO_GUI           = 2
    BAD_PARAMETER          = 3
    FILE_NOT_FOUND         = 4
    PATH_NOT_FOUND         = 5
    FILE_EXTENSION_UNKNOWN = 6
    ERROR_EXECUTE_FAILED   = 7
    SYNCHRONOUS_FAILED     = 8
    NOT_SUPPORTED_BY_GUI   = 9
    OTHERS                 = 10.

Read only

0 Likes
1,220

REPORT ZCOMMAND NO STANDARD PAGE HEADING.

PARAMETERS: CMD(30) DEFAULT 'd:\restart.bat' LOWER CASE.

call function 'GUI_EXEC'
  exporting
    command          = CMD.

if the batch file is on the server is to use transactions SM69 and SM49 and then function module SXPG_COMMAND_EXECUTE.

Read only

0 Likes
1,220

i think the command should be UPPER CASE,

Edited by: eric.yang on Sep 23, 2009 10:46 AM

Read only

0 Likes
1,220

>

> i think the command should be UPPER CASE,

>

> Edited by: eric.yang on Sep 23, 2009 10:46 AM

No need of uppercase eric. just imagine a situation. can you have two files in a same folder with same name but different case?

Read only

Former Member
0 Likes
1,220
CALL METHOD cl_gui_frontend_services=>execute