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: 

Table Control

Former Member
0 Kudos

Hi,

How to download the displayed data from table control to local excel file.

Is there any function module?

I am new for module pool so send step by step

Regards,

Sudha

4 REPLIES 4

Former Member
0 Kudos

Hi,

Use GUI_DOWNLOAD.

Reward if helpful.

0 Kudos

Thanks,

Can you send breifly if you have model code send it also.

-Sudhakaran-

Former Member
0 Kudos

HI,

For every table control we have an internal table related to it, look at the PBO and PAI, you come to know which internal table is using to fill this table control, then use the GUI_DOWNLOAD function moduel to download this internal table data into Excel.

its a simple way to do what is required

CALL FUNCTION 'MS_EXCEL_OLE_STANDARD_DAT'

EXPORTING

FILE_NAME = 'C:\test\yourfile.xls'

  • CREATE_PIVOT = 0

  • DATA_SHEET_NAME = ' '

  • PIVOT_SHEET_NAME = ' '

  • PASSWORD = ' '

  • PASSWORD_OPTION = 0

TABLES

  • PIVOT_FIELD_TAB =

DATA_TAB = itab " internal table to be passed

  • FIELDNAMES =

EXCEPTIONS

FILE_NOT_EXIST = 1

FILENAME_EXPECTED = 2

COMMUNICATION_ERROR = 3

OLE_OBJECT_METHOD_ERROR = 4

OLE_OBJECT_PROPERTY_ERROR = 5

INVALID_PIVOT_FIELDS = 6

DOWNLOAD_PROBLEM = 7

OTHERS = 8

Regards

Sudheer

Former Member
0 Kudos

Hi,

First create a command button(FCT Code - 'WRITE') on the layout. then in the PAI of the layout write the code: & read the data from the tabe control or you can use the same internal table to download the data, used for displaying the data.


DATA: v_file type string.

Case sy-ucomm.
When 'WRITE'.

v_file = c:text.xls

CALL FUNCTION 'GUI_DOWNLOAD'
    EXPORTING
      filename = v_file
      write_field_separator = 'X'
    TABLES
      data_tab                = itab
    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 <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
            WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  ENDIF.

endcase.

Try the following func. module:

If you are working on 4.7 or later version the try GUI_'GUI_DOWNLOAD' Or if you are working on 4.6 or lower version then try 'WS_DOWNLOAD'

Reward points if helpful answer.

Asvhender