cancel
Showing results for 
Search instead for 
Did you mean: 

How to call a local EXE

Former Member
0 Kudos

Hi all,

how can i call a local EXE File from Abap ?

I have a Program "D:\test\runit.exe" that i need to call from a Abap Program. How can i do this and how can i pass a parameter to it ?

For example : D:\test\runit.exe convert.xml

Greetings

Henning

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi

This is an example to open pdf file

CALL METHOD cl_gui_frontend_services=>execute

EXPORTING

  • DOCUMENT =

APPLICATION = 'AcroRd32.exe'

PARAMETER = 'C:\MY_FILE.PDF'

  • DEFAULT_DIRECTORY =

  • MAXIMIZED =

  • MINIMIZED =

  • SYNCHRONOUS =

  • OPERATION = 'OPEN'

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.

ENDIF.

Max

Answers (3)

Answers (3)

Former Member
0 Kudos
 DATA: v_path(40).
  v_path = 'c:notepad.exe'.
  CALL FUNCTION 'GUI_EXEC'
    EXPORTING
      command          = v_path
*   PARAMETER        =
* IMPORTING
*   RETURNCODE       =
            .

Regards

Abhishek Suppal

Former Member
0 Kudos

REPORT ZWSEXECUTE.

DATA: BEGIN OF ITAB OCCURS 3,

LINE(50),

END OF ITAB.

PARAMETERS: PROG(70) DEFAULT

'C:\Program Files\Microsoft Office\Office\WINWORD.EXE'.

PARAMETERS: FILE1(70) DEFAULT 'C:\TEMP\TEST.TXT'.

  • Tick to print the Text file after saving from MS

WORDS

PARAMETERS: S_UP AS CHECKBOX.

  • Tick to create new or overwrite Text file

PARAMETERS: S_NEW AS CHECKBOX.

IF S_UP = 'X'.

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

FILENAME = 'FILE1'

TABLES

DATA_TAB = ITAB

EXCEPTIONS

FILE_OPEN_ERROR = 1.

IF SY-SUBRC = 0.

LOOP AT ITAB.

WRITE: / ITAB.

ENDLOOP.

ELSE.

WRITE: / 'File open error.'.

ENDIF.

ELSE.

IF S_NEW = 'X'.

CALL FUNCTION 'GUI_DOWNLOAD'

EXPORTING

FILENAME = 'FILE1'

TABLES

DATA_TAB = ITAB

EXCEPTIONS

FILE_WRITE_ERROR = 1

NO_BATCH = 2

GUI_REFUSE_FILETRANSFER = 3

INVALID_TYPE = 4

OTHERS = 5.

ENDIF.

CASE SY-SUBRC.

WHEN 1.

WRITE: / 'GUI DOWNLOAD FILE WRITE ERROR'.

WHEN 2.

WRITE: / 'GUI DOWNLOAD NO BATCH'.

WHEN 3.

WRITE: / 'GUI DOWNLOAD GUI REFUSE

FILETRANSFER'.

WHEN 4.

WRITE: / 'GUI DOWNLOAD INVALID TYPE'.

WHEN 5.

WRITE: / 'GUI DOWNLOAD OTHERS'.

ENDCASE.

CALL FUNCTION 'WS_EXECUTE'

EXPORTING

PROGRAM = PROG

COMMANDLINE = 'FILE1'

INFORM = ' '

EXCEPTIONS

FRONTEND_ERROR = 1

NO_BATCH = 2

PROG_NOT_FOUND = 3

ILLEGAL_OPTION = 4

GUI_REFUSE_EXECUTE = 5

OTHERS = 6.

CASE SY-SUBRC.

WHEN 1.

WRITE: / 'FRONTEND ERROR'.

WHEN 2.

WRITE: / 'NO BATCH'.

WHEN 3.

WRITE: / 'PROGRAM NOT FOUND'.

WHEN 4.

WRITE: / 'ILLEGA OPTION'.

WHEN 5.

WRITE: / 'GUI REFUSE EXECUTE'.

WHEN 6.

WRITE: / 'OTHERS'.

ENDCASE.

ENDIF.

ABAP Tips by: Anshu Kumar

I have a tool in my desktop. Its in D drive. The file created should get stored in the d drive in the mentioned folder. The tool I am using is of exe mode. What parameters do I need to pass in the function module i.e for command line and program. Where should I mention the path of the tool and where (in which parameter) should I mention the input file path and the output file path.

CALL FUNCTION 'C13Z_FRONTEND_FILENAME_GET' " File_name

IMPORTING

e_filename = w_filename.

IF sy-subrc <> 0.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

  • Function to execute the Bar-Code batch file.

CALL FUNCTION 'WS_EXECUTE'

EXPORTING

cd = 'C:\'

program = 'C:\BARCODE2\BCIL.BAT'

EXCEPTIONS

frontend_error = 1

no_batch = 2

prog_not_found = 3

illegal_option = 4

gui_refuse_execute = 5

OTHERS = 6.

By this function you can take location & name from end user & then use this w_filename to save the file.

suresh_datti
Active Contributor
0 Kudos

Hi Henning,

During old days it used to be WS_EXECUTE.. I guess there are some GUI methods in the OO world now.. PL take a look at the function group SFES.

Regards,

Suresh Datti