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 bat-files

Former Member
0 Likes
889

Hallo,

I have a problem with the new method execute.

We have used gui_exec to run a bat-file with

> command = c:\file.bat

> parameter = "c:\my file.txt"

Now we do the same with the execute.

> application = c:\file.bat

> parameter = "c:\my file.txt"

but this does not work.

It works without the quotes, when the path

has no blanks in it. But it's the user

how chose the path ...

Regards,

Christine

5 REPLIES 5
Read only

Former Member
0 Likes
677

Hello,

I suppose the problem isn't GUI_EXEC, but the batch-file. If I create a batch file like this:


notpad %1

and execute


GUI_EXEC with 
command = c:temptest.bat and 
parameter = "C:TEMPNEU TEXTDATEI.TXT" 

(first without, second with quotes), everything works fine...

Hope this helps (please reward me if it does

Joerg

Read only

0 Likes
677

Hello Joerg,

the gui_exec works, the problem is the new

cl_gui_frontend_services=>execute!

We have also modify the batch with something like

notepad "%*"

but this doesn't work with NT.

I have noticed this:

I can debug the batch-file when I call it like

this:

call method cl_gui_frontend_services=>Execute

exporting

application = c:\test.bat

parameter = 'c:\te st.txt'

or

parameter = c:\te st.txt

but the dos-window close immediatly without

showing anything when I use

parameter = "c:\te st.txt"

Any ideas??

Regards,

Christine

Read only

0 Likes
677

Hello Christine,

When I look at the source of cl_gui_fronent_services->execute, I see that command an parameters are simply concatenated and then transferred to a FM where they are then sent to the SAP GUI "as is":


concatenate name space parameter into name separated by space.

Could you put the following debugging code at the start of your batch file in order to test what's going on exactly:


echo >dump.txt Command line: {%*} 
set cnt=1
:loop
if 1%1==1 goto end
echo >>dump.txt Command line arg #%cnt%: {%1}
shift
set /a cnt=%cnt% + 1
goto loop
:end

rem Rest of batch file starts here.

Regards, Joerg

Read only

0 Likes
677

Hello Joerg,

thanks for the debugging code for the batch.

I have done a lot of tests with NT and XP:

***************************

para = l_parameter.

com = l_application.

*CALL FUNCTION 'GUI_EXEC'

  • EXPORTING

  • COMMAND = com

  • PARAMETER = para.

or

  • CALL METHOD CL_GUI_FRONTEND_SERVICES=>EXECUTE

  • EXPORTING

  • APPLICATION = l_application

  • PARAMETER = l_parameter.

*********************************************

Testing with NT

With the GUI_EXEC I get the file dump.txt with:

Command line: { "D:\test mit leer\mit_.txt"}

Command line arg #1: {"D:\test mit leer\mit_.txt"}

The same with EXECUTE: there is no dump.txt-file.

Testing with XP:

both the GUI_EXEC and the EXECUTE are writing

the dump.txt-file with the same content as above.

So the problem is only with NT and there are

only a few with it left. They have to use path

without blank or use XP ...!

Thanks for your help.

Regards,

Christine

Read only

0 Likes
677

Hi Christine!

Would you mind closing this thread?

Regards, Joerg