Application Development 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: 

Execute file exe stored on application server

Former Member
0 Kudos

Hi all

my question is simple:

Is it possible in abap to execute a program (.bat file) stored on server? In background would be great ...

thanks

Gabriele

1 ACCEPTED SOLUTION

Pawan_Kesari
Active Contributor
0 Kudos

Create an external command in transaction SM69, specifying path of batch file on server.

Write an  ABAP program which will run this external command defined in SM69 using function module SXPG_COMMAND_EXECUTE.  You can then schedule you ABAP program to run batch file.

Regards,

Pawan.

6 REPLIES 6

Former Member
0 Kudos

BAT file would mean Windows commands.

If application server is running Windows operating system, batch file can be executed, in background.

Pawan_Kesari
Active Contributor
0 Kudos

Create an external command in transaction SM69, specifying path of batch file on server.

Write an  ABAP program which will run this external command defined in SM69 using function module SXPG_COMMAND_EXECUTE.  You can then schedule you ABAP program to run batch file.

Regards,

Pawan.

0 Kudos

if the batch file is not located in application server and the client system then also can we run it?

Means lets say the batch file is located a another server other than client system and application server. Can we run it through sm69?

Former Member
0 Kudos

Hi Gabriele,

Follow the steps:

1) Define external operating system command say zcopytm1 using SM69 by using the following parameters:

Command name                            Operating system       Type

ZCOPYTM1                                Windows NT             Customer

Operating system command

e:\tm1out\tm1ph.bat

Parameters for operating system command

Leave this blank

tm1ph.bat is the batch file which it will execute.

2) First test it using SM49. Once satisfied use the following code to execute it thru ABAP:

DATA: BEGIN OF t_copy OCCURS 1.        

INCLUDE STRUCTURE btcxpm.

DATA: END OF t_copy.

DATA:      statusline LIKE btcxp3-exitstat.    

CALL FUNCTION 'SXPG_COMMAND_EXECUTE'         

EXPORTING            

commandname            = 'zcopytm1'            

status                              = statusline         

TABLES            

exec_protocol                       = t_copy         

EXCEPTIONS            

no_permission                       = 1            

command_not_found                   = 2            

parameters_too_long                 = 3            

security_risk                       = 4            

wrong_check_call_interface          = 5           

program_start_error                 = 6            

program_termination_error           = 7            

x_error                             = 8            

parameter_expected                  = 9            

too_many_parameters                 = 10            

illegal_command                     = 11            

wrong_asynchronous_parameters       = 12            

cant_enq_tbtco_entry                = 13            

jobcount_generation_error           = 14        

OTHERS                              = 15.

Hope it helps

Former Member
0 Kudos

In which server you want the run the batch file?

Former Member
0 Kudos

Thank you all. It worked both SM69 and SXPG_COMMAND_EXECUTE