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 dos command

Former Member
0 Likes
781

I am trying to execute a dos command thru sap and specific the delete command.

i tried in 2 ways (i read it to the forum) but i can't do it.

a) DATA : FILE(100),

PARAM(50),

COMM(30).

COMM = 'DEL.COM'.

CONCATENATE 'C:\' 'A.TXT' INTO FILE.

CALL FUNCTION 'GUI_RUN'

EXPORTING

COMMAND = COMM

PARAMETER = FILE.

b) CALL METHOD cl_gui_frontend_services=>execute

EXPORTING

  • DOCUMENT = 'C:\A.TXT'

application = 'YDEL'

parameter = 'C:\A.TXT'

  • DEFAULT_DIRECTORY =

MAXIMIZED = 'X'

  • MINIMIZED =

  • SYNCHRONOUS =

OPERATION = 'OPEN'

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.

Please help me ...

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
547

i tried but it doesn't work . It open a dos window with the cmd command but later it doesn't do anything . Which way you tried ?

What did you wrote ?

3 REPLIES 3
Read only

Former Member
0 Likes
547

Hi dimath,

1. I just tried, and now it works.

2. give like this. (we have to use CMD as the command and not DEL)

3.

<b>COMMAND = CMD

PARAMETER = DEL D:\ABC.TXT</b>

regards,

amit m.

Read only

Former Member
0 Likes
548

i tried but it doesn't work . It open a dos window with the cmd command but later it doesn't do anything . Which way you tried ?

What did you wrote ?

Read only

0 Likes
547

Hi dimath,

1. sorry, now this will work.

(this will not even open the dos window)

(it will get opened only for a fraction of seconds, and then get closed automatically)

the file will get deleted.

2.

command = CMD

parameter = /C DEL D:\AA.TXT

(note /C is important)

regards,

amit m.