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

Execute a .exe file present in the Application Server

Former Member
0 Likes
2,031

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.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,445

Go to SM69, maintain your exe as external command and then call it in your code using SXPG_COMMAND_EXECUTE.

8 REPLIES 8
Read only

Former Member
0 Likes
1,445

Please respond

Read only

Former Member
0 Likes
1,445

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.

Read only

Former Member
0 Likes
1,445

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.

Read only

0 Likes
1,445

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??

Read only

0 Likes
1,445

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?

Read only

Former Member
0 Likes
1,446

Go to SM69, maintain your exe as external command and then call it in your code using SXPG_COMMAND_EXECUTE.

Read only

0 Likes
1,445

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.

Read only

Former Member
0 Likes
1,445

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.