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: 

Transfer internal table data into MSword

Former Member
0 Kudos

Hi Gurus,

I want to display the data that i fetched to internal table in msword.means i want to see the output in msword.please provide me the sample code.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

Use GUI_DOWNLOAD function module. give filename as

<filename>.doc


   CALL FUNCTION 'GUI_DOWNLOAD'
    EXPORTING
      filename                = 'D:\flight.doc'  "<----extension for Msword file
      filetype                      = 'ASC'
   

Regards

Abhijeet

11 REPLIES 11

Former Member
0 Kudos

Hi,

Use GUI_DOWNLOAD function module. give filename as

<filename>.doc


   CALL FUNCTION 'GUI_DOWNLOAD'
    EXPORTING
      filename                = 'D:\flight.doc'  "<----extension for Msword file
      filetype                      = 'ASC'
   

Regards

Abhijeet

0 Kudos

Hi Abhi,

transfer the data means i want to see the data in msword when i press execute button.i think i have to use OLE.but i dont have much knowledge on that.if you know how to please tell me.

0 Kudos

Hi,

Check this sample code, by this code data of internal table will be downloaded in MSWORD file with name Flight.


REPORT  z_FILE_DOWNLOAD.
DATA: w_name(90) TYPE c.
DATA:
  BEGIN OF fs_flight,
    carrid   LIKE sflight-carrid,
    connid   LIKE sflight-connid,
    fldate   LIKE sflight-fldate,
    price    LIKE sflight-price,
    currency LIKE sflight-currency,
  END OF fs_flight.

DATA:
  t_flight LIKE
     TABLE OF
           fs_flight.


SELECT-OPTIONS:
  s_carrid FOR fs_flight-carrid.


START-OF-SELECTION.
  SELECT carrid
         connid
         fldate
         price
         currency
    FROM sflight
    INTO TABLE t_flight
   WHERE carrid IN s_carrid.


CALL FUNCTION 'GUI_DOWNLOAD'
  EXPORTING

filename =            'D:\flight.doc'

   FILETYPE                      = 'ASC'

   WRITE_FIELD_SEPARATOR         = 'X'

  tables
    data_tab                      = t_flight
 EXCEPTIONS
   FILE_WRITE_ERROR              = 1
   NO_BATCH                      = 2
   GUI_REFUSE_FILETRANSFER       = 3
   INVALID_TYPE                  = 4
   NO_AUTHORITY                  = 5
   UNKNOWN_ERROR                 = 6
   HEADER_NOT_ALLOWED            = 7
   SEPARATOR_NOT_ALLOWED         = 8
   FILESIZE_NOT_ALLOWED          = 9
   HEADER_TOO_LONG               = 10
   DP_ERROR_CREATE               = 11
   DP_ERROR_SEND                 = 12
   DP_ERROR_WRITE                = 13
   UNKNOWN_DP_ERROR              = 14
   ACCESS_DENIED                 = 15
   DP_OUT_OF_MEMORY              = 16
   DISK_FULL                     = 17
   DP_TIMEOUT                    = 18
   FILE_NOT_FOUND                = 19
   DATAPROVIDER_EXCEPTION        = 20
   CONTROL_FLUSH_ERROR           = 21
   OTHERS                        = 22
          .
IF sy-subrc EQ 0.
  MESSAGE 'Download successful' TYPE 'S'.
ELSE.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.

Regards

Abhijeet

0 Kudos

Hi,

Use the code below to download and show in word.

CALL FUNCTION 'GUI_DOWNLOAD'
  EXPORTING
filename =            'c:\file.doc'
FILETYPE                      = 'ASC'
WRITE_FIELD_SEPARATOR         = 'X'
tables
    data_tab                      = itab_data.

IF sy-subrc eq 0.
CALL FUNCTION 'GUI_RUN'
  EXPORTING
    command          = 'WINWORD'
   PARAMETER        = 'c:\file.doc'.
ENDIF.

Regards

Karthik D

0 Kudos

Hi Karthik,

This is help me.But it is creating a file in clients system.i want to display the output in msword without saving the data.

Thnaks for your response.

0 Kudos

If you dont want the file just give the file path to temp folder.

But i think what you need cannot be done without storing the file in the system.

Regards

Karthik D

0 Kudos

Hi Karthik,

If i use the path like "D:\file" it will work if we have d drive.otherwise it will not .we are not sure that the client will have the same drives.please check it once.

0 Kudos

Hi,

Use the following FM to get file name& path from the user before the above said function modules and assign the lv_filename to GUI_DOWNLOAD and GUI_RUN Fms.


data : lv_filename TYPE string, 
         lv_path TYPE string,     
         lv_fullpath TYPE string.

CALL METHOD cl_gui_frontend_services=>file_save_dialog
      EXPORTING
        window_title         = 'Save as'
        default_extension    = 'doc'
        default_file_name    = 'file.doc'
        file_filter          = '*.doc'
        prompt_on_overwrite  = 'X'
      CHANGING
        filename             = lv_filename
        path                 = lv_path
        fullpath             = lv_fullpath
      EXCEPTIONS
        cntl_error           = 1
        error_no_gui         = 2
        not_supported_by_gui = 3
        OTHERS               = 4.

This will show the file save dialog box and get the path from the user.

Regards

Karthik D

Former Member
0 Kudos

hii

we can download data in to .txt or .xls and .doc using gui_download FM.also try using

POPUP_AND_DOWNLOAD_FOR_WORD

CALL FUNCTION 'GUI_DOWNLOAD'
    EXPORTING
*   BIN_FILESIZE                  =
 filename   = 'C:\Documents and Settings\Desktop\twi1.doc'
     filetype                      = 'ASC'
*   APPEND                        = ' '
*     write_field_separator         = 'X'
*   HEADER                        = '00'
*   TRUNC_TRAILING_BLANKS         = ' '

regards

twinkal

Former Member
0 Kudos

HELLO

YOU WANT TO DOWNLOAD WORD FILE USE FM - GUI_DOWNLOAD IN FILE NAME PARAMETER WHERE YOU GIVE PATH THERE U GIVE (.DOC AT LAST).

HOPE THIS WILL HELP YOU.

Former Member
0 Kudos

Hi,

use OLE in abap. In Tcode DWDM you find some example.

Regards, Dieter