REPORT YDOSEXEC.

PARAMETERS: LINE(50).

DATA: START_TIME TYPE T, END_TIME TYPE T.

DATA: BEGIN OF ITAB OCCURS 3,
LINE(50),
END OF ITAB.

ITAB-LINE = LINE.
APPEND ITAB.

CALL FUNCTION 'WS_DOWNLOAD'
     EXPORTING
          FILENAME = 'C:\TEMP\TEST.TXT'
     TABLES
          DATA_TAB = ITAB.

CALL FUNCTION 'WS_EXECUTE'
     EXPORTING
          PROGRAM       = 'C:\MSOFFICE\WINWORD\WINWORD.EXE'
          COMMANDLINE   = 'C:\TEMP\TEST.TXT'
          INFORM        = ''
     EXCEPTIONS
          PROG_NOT_FOUND.

GET TIME.
START_TIME = SY-UZEIT.
END_TIME   = SY-UZEIT + 20.
DO.
  GET TIME.
  START_TIME = SY-UZEIT.
  IF START_TIME >= END_TIME.
    EXIT.
  ENDIF.
ENDDO.

CLEAR ITAB.
REFRESH ITAB.
CALL FUNCTION 'WS_UPLOAD'
     EXPORTING
          FILENAME        = 'C:\TEMP\TEST.TXT'
     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.