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

Calling external program on application server

Former Member
0 Likes
3,317

Hi, everyone. I'm trying to call an external program from ABAP by using SM69 and FM SXPG_COMMAND_EXECUTE

MOVE 'zlong_bat' to ld_comline.         "Maintained using trans SM69
*
* Execute external command, contained in 'ld_comline'
  CALL FUNCTION 'SXPG_COMMAND_EXECUTE'
       EXPORTING
            commandname                   = ld_comline
*           additional_parameters   = ld_param  "Params passed to script
*           operatingsystem               = 'UNIX'
       IMPORTING
            status                        = ld_status
       TABLES
            exec_protocol                 = ld_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.
  IF sy-subrc NE 0.

  ENDIF.

In the sm69, I define zlong_bat with

Operating system command: cmd

Parameters for operating system command: /c remoteconn.bat

It can run well if remoteconn.bat contain some simple command of dos like dir, md, mk... But when I call a program from remoteconn.bat, the abap program hang. I also cannot test in sm69 because it hang too.

If I call direcly from sm 69 with

Operating system command: cmd

Parameters for operating system command: /c psexec.exe
localhost -u test -p 1234

or

Operating system command: C:\psexec.exe

Parameters for operating system command:
localhost -u test -p 1234

The SM69 also hang.

Are there any method to call a program from sap without hanging

of course the program is in its position on application server.

Thank you in advance.

Regards,

Long

Edited by: dragonking88 on Aug 25, 2010 12:54 PM

5 REPLIES 5
Read only

Former Member
0 Likes
1,411

I would expect that SM69 is sending commands directly to your operating system (UNIX), and UNIX doesn't know what to do with that desktop command.

Read only

0 Likes
1,411

Unfortunately, my application server is using Windows Server 2003

Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
1,411

While calling the FM 'SXPG_COMMAND_EXECUTE' pass space to the interface param TERMINATIONWAIT.

BR,

Suhas

Read only

Former Member
0 Likes
1,411

I found the answer myself. Just a stupid mistake. The external program need to be confirm the Agreement at the first time program run.!!

Read only

0 Likes
1,411

Hi Long Le Hoang,

I am running a shell script fromSM69 which call psexec.

shell script runs fine but SM69 execution goes on hold.

Can you please help me how to terminate SM69 execution.

Alpa