Google Search - Blog...........

ABAP - Sample Program To Open A File On The System Using FM WS_EXECUTE.

REPORT ZUM_OPEN_WORD .

* The internal table is declared of size 3
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.

ALSO READ:

- Download Code To System Using FM RS_TESTFRAME_CALL.

- Download Code To The Desktop With Screens.

- Uploading Data From Excel Sheet To Internal Table Using FM ALSM_EXCEL_TO_INTERNAL_TABLE.

- Uploading Images From PC To An Internal Table Using FM BDS_BUSINESSDOCUMENT_CREATEF.

- Uploading Data To The FTP Server Using FM GUI_UPLOAD And FILE_GET_NAME.


RETURN TO MAIN INDEX:

- Sample Programs On Uploading & Downloading Files.

- Sample Programs On HR ABAP.

- Sample Report Programs On ALV List/ Grid Display.

- Sample Programs On Selection Screen.

- Sample Programs On BDC.

.....Back To MAIN INDEX.

No comments:

Post a Comment