0% found this document useful (0 votes)
317 views

Ws - Execute Function Module To Call An External Program

ws_execute function module to call an external program.rtf
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as RTF, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
317 views

Ws - Execute Function Module To Call An External Program

ws_execute function module to call an external program.rtf
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as RTF, PDF, TXT or read online on Scribd
You are on page 1/ 6

WS_EXECUTE to called External Program How to work with ws_execute function module to call an external program?

ws_execute used for Calling Microsoft Word from ABAP

=>Let user type in the text file with Microsoft Word Use WS_EXECUTE to activate Microsoft Word from ABAP. After saving, exit from Microsoft Word and upload the files to Internal Table for printing.

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 TABLES DATA_TAB EXCEPTIONS FILE_OPEN_ERROR = 1. = ITAB = 'FILE1'

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 =3

GUI_REFUSE_FILETRANSFER INVALID_TYPE OTHERS ENDIF. CASE SY-SUBRC. WHEN 1. =4 = 5.

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 PROG_NOT_FOUND ILLEGAL_OPTION

=2 =3 =4 =5

GUI_REFUSE_EXECUTE 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 IF sy-subrc <> 0. MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4. ENDIF. = w_filename.

* Function to execute the Bar-Code batch file. CALL FUNCTION 'WS_EXECUTE' EXPORTING cd program EXCEPTIONS frontend_error no_batch prog_not_found illegal_option =1 =2 =3 =4 = 'C:\' = 'C:\BARCODE2\BCIL.BAT'

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. ABAP Tips by: Anil Khandelwal

Fast Links:

Get help for your ABAP problems Do you have a ABAP Question?

ABAP Books ABAP Certification, BAPI, Java, Web Programming, Smart Forms, Sapscripts Reference Books

ABAP Tips ABAP Forum for Discussion and Samples Program Codes for Abapers

Best regards, SAP Basis, ABAP Programming and Other IMG Stuff http://www.erpgreat.com

All the site contents are Copyright www.erpgreat.com and the content authors. All rights reserved. All product names are trademarks of their respective companies. The site www.erpgreat.com is in no way affiliated with SAP AG. Every effort is made to ensure the content integrity. Information used on this site is at your own risk. The content on this site may not be reproduced or redistributed without the express written permission of www.erpgreat.com or the content authors.

You might also like