‎2009 Jul 16 11:24 AM
Hi,
I need to execute .sh file in SUN operating system.If there is any function module to execute?Please help me.Its very urgent.My OS is windows.
‎2009 Jul 16 11:28 AM
Hi Satish,
Try this Function Module SXPG_COMMAND_EXECUTE( For Executing External OS Commands)
Regards,
Lakshman.
‎2009 Jul 16 11:43 AM
Hi Lakshman,
Please tell the use of addparam in that functional module.Anything i need to pass?
‎2009 Jul 16 12:26 PM
Hi Satish,
Chk this link
https://wiki.sdn.sap.com/wiki/display/Snippets/WrapperClassforexecutingExternal+Commands
‎2009 Jul 16 1:20 PM
Hi Satish,
The additional parameters field of the function module 'SXPG_COMMAND_EXECUTE' depends on the external system your going to call. You can pass details like server name, user name or incase of unix system, the parameter file path etc, concatenated into a single variable and pass to that parameter in the function module.
Regards,
Vik
‎2009 Jul 16 11:29 AM
HI,
Try Function 'GUI_EXEC' for yopur requirement. As I've run this for DOS through SAP.
DOS Execution :
CALL FUNCTION 'GUI_EXEC'
EXPORTING
COMMAND = 'C:\ABC.BAT'.
Regds,
Anil
‎2009 Jul 16 11:34 AM
Hi Sathish, <li> Use CL_GUI_FRONTEND_SERVICES->EXECUTE method to run OS applications or <li> Use GUI_EXEC function module. Thanks Venkat.O
‎2009 Jul 16 11:49 AM
If the file to be executed is in another independent server.
1. First, you need to connect to that server with username, password using FM: FTP_CONNECT.
2. After logging-in successfully, execute the command using FM: FTP_COMMAND.
Here is a sample code which invokes change directory command cd /user/JOHN in remote system,
which changes present working directory (pwd) to /user/JOHN.
ENCRYPT PASSWORD
data : w_key type i value 26101957,
CALL 'AB_RFC_X_SCRAMBLE_STRING'
ID 'SOURCE' FIELD f_password
ID 'KEY' FIELD w_key
ID 'SCR' FIELD 'X'
ID 'DESTINATION' FIELD f_password
ID 'DSTLEN' FIELD w_pwd_len.
CALL FUNCTION 'FTP_CONNECT'
EXPORTING
USER = user
PASSWORD = password
ACCOUNT =
HOST = remote_server_name
RFC_DESTINATION = 'SAPFTPA'
GATEWAY_USER =
GATEWAY_PASSWORD =
GATEWAY_HOST =
IMPORTING
HANDLE = handle
EXCEPTIONS
NOT_CONNECTED = 1
OTHERS = 2
.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
concatenate 'cd' '/user/ into command separated by space.
CALL FUNCTION 'FTP_COMMAND'
EXPORTING
HANDLE = handle
COMMAND = command
COMPRESS =
VERIFY =
RFC_DESTINATION = 'SAPFTPA'
IMPORTING
FILESIZE =
FILEDATE =
FILETIME =
TABLES
DATA = result
EXCEPTIONS
TCPIP_ERROR = 1
COMMAND_ERROR = 2
DATA_ERROR = 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.