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

SXPG_COMMAND_EXECUTE Can't exec external program (No such file or directory

Former Member
0 Likes
5,557

Hi Experts,

I need to launch or terminate an external application (i.e. command prompt, notepad, etc.) in background job by using FM SXPG_COMMAND_EXECUTE. However, I am unable to proceed because of the following error occured after executing the command in SM69.

Can't exec external program (No such file or directory)

External program terminated with exit code 1

I was using the following sample code. Can someone tell me what might be the cause of the problem?

DATA: lv_status TYPE extcmdexex-status,
      lt_output TYPE TABLE OF btcxpm,
      lv_opsys  TYPE sy-opsys.

lv_opsys = 'WINDOWS NT'.
CALL FUNCTION 'SXPG_COMMAND_EXECUTE'
  EXPORTING
    commandname                   = 'ZIEXPLORE'
    additional_parameters         = '/c'
    operatingsystem               = lv_opsys
  IMPORTING
    status                        = lv_status
  TABLES
    exec_protocol                 = lt_output
  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.

ZIEXPLORE command

Operating system command: cmd

Parameters for operating system command: taskkill /f /im iexplore.exe

Thanks and Regards,

Louie

12 REPLIES 12
Read only

kesavadas_thekkillath
Active Contributor
0 Likes
2,841

Hi,

I think you have mention it in SM69 under operating system command like cmd /c taskkill /f /im iexplore.exe and the remove additional_parameters = '/c' and check it

Read only

0 Likes
2,841

Hi Keshav,

I tried it and the error is just the same. I intended to put /c in the additional parameters to close the command prompt after execution.

Read only

0 Likes
2,841

lv_opsys = 'WINDOWS NT'.

In Sm69 is this given in all upper case, if not give as its given in SM69 and try it once again.

Kesav

Read only

0 Likes
2,841

Yes it is. I also tried passing 'Windows NT' but it raised an exception command_not_found. I believe i'm passing the right operating system in it's correct case.

Read only

kesavadas_thekkillath
Active Contributor
0 Likes
2,841

Is this command working fine from Sm49 ?

Read only

0 Likes
2,841

Not as well

Read only

0 Likes
2,841

Now you reached the root cause of your problem. Happy to know that

Contact your basis team and get it corrected.

Kesav

Read only

0 Likes
2,841

Hi Keshav,

I tried your suggestion, and our basis are just adjusting the authorizations seen in SU53. I also browsed the related objects to this which are S_LOG_COM & S_RZL_ADM and I believe I already have authorizations to those. Do you think this was really the cause of the issue? By the way, I tried to run SXPG_COMMAND_EXECUTE using the following parameters below and it works fine. That's why I really have a doubt if the problem is with basis. Might be with the RFC connections in SM59. Please help. Thanks!

Operating System: UNIX

Operating System Command: ls

Parameters for operating system command: /usr/sap/tmp

Read only

0 Likes
2,841

Hi Louie,

I am not able to assume the reason of the problem, If you say that its not getting executed in SM49 then the problem lies there.

So I am providing you a link which might be helpful, just go through it and cross check. There is a parameter called "trace" in the fm mentioned.

Secton Microsoft Windows NT - [Prerequisites for Running External Commands and External Programs|http://help.sap.com/saphelp_nw70/helpdata/en/c4/3a7fbb505211d189550000e829fbbd/content.htm]

[Analyzing Problems with External Commands and Programs|http://help.sap.com/saphelp_nw70/helpdata/en/c4/3a80c4505211d189550000e829fbbd/content.htm]

May be you can post this question in [SAP AS General|; also.

Read only

0 Likes
2,841

Hi Louie,

if authorizations and parameters are correctly set, check below tables

SXPGCOSTAB

SXPGCOTABE

also try SY-OPSYS.

Regards,

Ravi.

Read only

0 Likes
2,841

Hi Ravi,

I saw that the custom and standard external commands are in SXPGCOSTAB and SXPGCOTABE tables respectively. Is it necessary that SY-OPSYS from the system should be passed and not the operating system created in SM69?

Read only

0 Likes
2,841

Hi,

Obiveously not nesseary to pass SY-OPSYS.

In my system operating system names are defined in table SXPGCOTABE as

UNIX 
Windows NT

i thougnt about case(Upper/Lower) of parameters defined.

Regards,

Ravi.