‎2007 Sep 28 2:19 PM
Hi All,
I have a requiremnet where in we have to execute an .exe file present in the Application server .
Please let me know ASAP if there any Function Modules or methods to perform this operation .
Points to be rewarded.
‎2007 Sep 28 3:37 PM
Go to SM69, maintain your exe as external command and then call it in your code using SXPG_COMMAND_EXECUTE.
‎2007 Sep 28 2:45 PM
‎2007 Sep 28 3:23 PM
Hi Haritha,
Please try the below mentioned code.It might help.
REPORT zexe_0002.
DATA: idata_tab TYPE TABLE OF string.
DATA: xdata_tab TYPE string.
data: file1 type string.
PARAMETERS: p_file1 TYPE localfile DEFAULT 'c:\sapcar.exe',
p_file2 TYPE localfile DEFAULT '\usr\nsp\sys\sapcar.exe'.
start-of-selection.
file1 = p_file1.
call method cl_gui_frontend_services=>gui_upload
EXPORTING
filename = file1
filetype = 'ASC'
CHANGING
data_tab = idata_tab
EXCEPTIONS
file_open_error = 1
file_read_error = 2
no_batch = 3
gui_refuse_filetransfer = 4
invalid_type = 5
no_authority = 6
unknown_error = 7
bad_data_format = 8
header_not_allowed = 9
separator_not_allowed = 10
header_too_long = 11
unknown_dp_error = 12
access_denied = 13
dp_out_of_memory = 14
disk_full = 15
dp_timeout = 16
not_supported_by_gui = 17
error_no_gui = 18.
OPEN DATASET p_file2 FOR OUTPUT IN BINARY MODE.
CHECK sy-subrc = 0.
LOOP AT idata_tab INTO xdata_tab.
TRANSFER xdata_tab TO p_file2.
ENDLOOP.
CLOSE DATASET p_file2.
In order to execute the file on the Application Server,you will have to go to AL11 and manually execute it.
In case you have any further clarifications,do let me know.
Regards,
Puneet Jhari.
‎2007 Sep 28 3:36 PM
Here is an example of executing operating systems commands from ABAP.
DATA unixcmd(200) TYPE c.
CONCATENATE g_dirn lh_rpt1-filen INTO unixcmd.
CONCATENATE 'mv' unixcmd g_dirn INTO unixcmd SEPARATED BY space.
CONCATENATE unixcmd 'bpcs/' lh_rpt1-filen INTO unixcmd.
Executing the system commands witin ABAP.
CALL 'SYSTEM' ID 'COMMAND' FIELD unixcmd.
‎2007 Sep 28 4:16 PM
Hi fred,
thanx for your reply.
can u please be more specific in the usage of this code .
I have checked with the below code
CONCATENATE '\usr\sap\R3S\SYS\exe\run\' 'MT.EXE' INTO unixcmd.
CONCATENATE 'mv' unixcmd '\usr\sap\R3S\SYS\exe\run\' INTO unixcmd SEPARATED BY space.
CONCATENATE unixcmd 'bpcs/' 'MT.EXE' INTO unixcmd.
CALL 'SYSTEM' ID 'COMMAND' FIELD unixcmd.
but i am not getting the required functionality.
My requirement is, suppose one EXE file has some functionality such one URL that should get opened. so that i can process that URL.Is it possible??
‎2007 Sep 28 4:34 PM
What is the purpose of this exe and what parameters do you have to pass to it and what is it going to return back?
‎2007 Sep 28 3:37 PM
Go to SM69, maintain your exe as external command and then call it in your code using SXPG_COMMAND_EXECUTE.
‎2007 Sep 28 4:19 PM
hi Srinivas,
Can u please explain the process of creating external command as i am not having any idea regarding this.Also give the procedure if possible.
‎2007 Sep 28 7:52 PM
Haritha,
You can execute a .exe file present on the application server using the followng code. Just assign the path and executable file name to the unixcmd variable.
data: unixcmd(100) type c.
unixcmd = '/directory/application.exe'.
Executing the system commands witin ABAP.
CALL 'SYSTEM' ID 'COMMAND' FIELD unixcmd.