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: 

how to call exe and get returned values ?

Former Member
0 Kudos

I wanna call pc exe from abap, after calling can i get results from exe ?

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

check this:

http://www.saptechies.com/ws_execute-to-called-external-program/

Use GUI_RUN instead of WS_EXECUTE.

Regards,

Subramanian

5 REPLIES 5

Former Member
0 Kudos

Go SM69, click create. Enter a command name 'ZZMYEXE', enter the path and the exe file name in operating system command field. You can call this exe from ABAP using SXPG_COMMAND_EXECUTE.

Please note that the exe has to exist on the server not on your PC or at least your PC (with fixed network address) should be accessable from server.

Former Member
0 Kudos

Hi,

check this:

http://www.saptechies.com/ws_execute-to-called-external-program/

Use GUI_RUN instead of WS_EXECUTE.

Regards,

Subramanian

venkat_o
Active Contributor
0 Kudos

Hi, Try this way.


REPORT ZTEST_NOTEPAD.
CALL METHOD CL_GUI_FRONTEND_SERVICES=>EXECUTE
  EXPORTING
    APPLICATION            = 'C:\Program Files\Easy GIF Animator\gifan.exe'
  EXCEPTIONS
    CNTL_ERROR             = 1
    ERROR_NO_GUI           = 2
    BAD_PARAMETER          = 3
    FILE_NOT_FOUND         = 4
    PATH_NOT_FOUND         = 5
    FILE_EXTENSION_UNKNOWN = 6
    ERROR_EXECUTE_FAILED   = 7
    SYNCHRONOUS_FAILED     = 8
    NOT_SUPPORTED_BY_GUI   = 9
    OTHERS                 = 10.
IF SY-SUBRC <> 0.
  MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
             WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
Thanks Venkat.O

Former Member
0 Kudos

thanks your responses . but i dont want operating system messages. I wanna see that for example ..

i am calling dos command dir ..

result lists all of content of directory ..

like this .. i wanna execute a pc exe and i wanna take result from exe .. can u help me ?

Former Member
0 Kudos

Hi,

for dos DIR you can use:


  DATA: COUNT TYPE I.
*
  DATA: WA_TAB_FILE   TYPE          FILE_INFO,
        TAB_FILE      TYPE TABLE OF FILE_INFO.
*
  CALL METHOD CL_GUI_FRONTEND_SERVICES=>DIRECTORY_LIST_FILES
    EXPORTING
      DIRECTORY  = 'C:\'
      FILTER     = '*'
    CHANGING
      FILE_TABLE = TAB_FILE
      COUNT      = COUNT.
*
  write: / 'count of files:', count.
*
  LOOP AT TAB_FILE INTO WA_TAB_FILE.
*
    WRITE: / WA_TAB_FILE-FILENAME(40),
             WA_TAB_FILE-FILELENGTH,
             WA_TAB_FILE-CREATEDATE,
             WA_TAB_FILE-ISDIR.
*
  ENDLOOP.

in CL_GUI_FRONTEND_SERVICES=>DIRECTORY_LIST_FILES there are more posibilities.

If you have another EXE on PC. Put the output of EXE in an FILE and read thie file via CL_GUI_FRONTEND_SERVICES.

Regards, Dieter