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

Tcode SM69 - External OS Command

Former Member
0 Likes
7,661

Hi guys,

I need help for tcode SM69

How do we access a BAT file from a directory path for example

C:\Program Files\Software_ABC\Deeper_folder\genxy.bat

Operating System = windows nt

Type = Customer

But I have no idea how to go about for the Operating System Command.

I'm supposed to run it like

C:\Program Files\Software_ABC\Deeper_folder\genxy.bat "E:\usr\sap\EWD\DVEBMGS00\data\File_20110107114455.xml"

Any advice? Appreciate it

9 REPLIES 9
Read only

Former Member
0 Likes
5,137

Anyone can assist?

basically how do we run the .bat file from a directory?

That .bat will then run to encrypt a xml file.

Read only

0 Likes
5,137

Hello,

In SM69 you have two fields for this.

In operating system command (obligatory) you put the actual command, this means the full path to your executable and the name of the executable, in your case : C:\Program Files\Software_ABC\Deeper_folder\genxy.bat

In the field Parameters for operating system command (not obligatory) : you put all your arguments, in your case the XML file.

The parameters field can be left empty, when you then start the command you can still define another value, in your case another XML file.

OS commands defined in SM69 are always executed on the server, sometimes there is a misunderstanding on this.

When you want to execute a .bat file that remains on another computer, example a simple workstation PC, you will need to use other SAP functionalities.

Success.

Wim Van den Wyngaert

Read only

0 Likes
5,137

Hi there,

thanks but when I try to run it,

I'm receiving

'C:\Program' is not recognized as an internal or external command, operable program or batch file. External program terminated with exit code 1

Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
5,137

Hello,

Are you trying to execute the external command in online mode or in background mode?

BR,

Suhas

PS:You can't run external commands in online mode.

Read only

0 Likes
5,137

Hello,

It seems that your command is truncated after the first blank.

I do not know the Windows world that much but did you try to put your command between double quotes ?

Example : "C:\Program Files\Software_ABC\Deeper_folder\genxy.bat"

I hope this helps.

Wim Van den Wyngaert

Read only

0 Likes
5,137

hhm

My program(web dynpro) will call it from a class which I have created.

So its like web dynpro > call a method from class > then method will execute FM SXPG_COMMAND_EXECUTE with the created External Command at SM69?

Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
5,137

Hello,

Looks like the .BAT file will be accessed online! If so try CL_GUI_FRONTEND_SERVICES=>EXECUTE instead of 'SXPG_COMMAND_EXECUTE'.

BR,

Suhas

Read only

Former Member
0 Likes
5,137

you create external command and pass command name in FM

CALL FUNCTION 'SXPG_COMMAND_EXECUTE'

or u can use following way


CONSTANTS: c_extcom    TYPE sxpgcolist-name VALUE 'ZTEST',
           c_oper      TYPE syopsys VALUE 'Windows NT'.

DATA: v_dir_input      TYPE sxpgcolist-parameters.  " Input Directory
DATA: t_result         TYPE STANDARD TABLE OF btcxpm.


v_dir_input = 'cmd /c C:\Program Files\Software_ABC\Deeper_folder\genxy.bat'.
CALL FUNCTION 'SXPG_COMMAND_EXECUTE'
  EXPORTING
    commandname                   = c_extcom
    additional_parameters         = v_dir_input
    operatingsystem               = c_oper
  TABLES
    exec_protocol                 = t_result
  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.


Read only

Former Member
0 Likes
5,137

hiii,

instead of using .bat extension use .xls or .xml bcoz in windows doesn't knw for which pgm the .bat file is used.

so using .xls would be easy and would get the output immediately.

hope it helps you.

regards,

akshay ruia