Application Development and Automation 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: 
Read only

How to export data from table control(module pool) to local file

Former Member
0 Likes
3,022

Hello all

i ahve requirement like below.

In module pool i am using Table control to display data.

I want to export data from table control(module pool) to local file like in ALV list.

can any one help me

Regards

radha

Hello all

i ahve requirement like below.

In module pool i am using Table control to display data.

I want to export data from table control(module pool) to local file like in ALV list.

can any one help me

Regards

radha

7 REPLIES 7
Read only

I355602
Product and Topic Expert
Product and Topic Expert
0 Likes
1,602

Hi,

You must be displaying data into table control from an internal table.

So an alternative is to create a button in dialog programming and then in user command at sy-ucomm for that button include a code for downloading the data into excel file using FM:-

GUI_DOWNLOAD

EXCEL_OLE_STANDARD_DAT

Pass the internal table and you will get data into an excel file with all the data.

Hope this helps you.

Thanks & Regards,

Tarun

Edited by: Tarun Gambhir on Feb 16, 2009 9:38 AM

Read only

Former Member
0 Likes
1,602

Hi Tarun,

Thanks for reply,

how to provide popup to select path and

if i want to provide popup like in ALV

how to achieve this.

regards

raadha

Read only

Former Member
0 Likes
1,602

Hope this one helps.............

if not it1[] is initial.

it1_xls-pcode = 'Product Code'.

it1_xls-desc = 'Group Description'.

it1_xls-subfam = 'Sub_Family'.

it1_xls-codcol = 'Tint'.

it1_xls-codcoat = 'Coating'.

it1_xls-epaiscom = 'Comm. Thickness'.

it1_xls-mcode = 'Material Code'.

it1_xls-del_flag = 'Deletion_Flag'.

append it1_xls.

loop at it1.

it1_xls-pcode = it1-pcode.

it1_xls-desc = it1-desc.

it1_xls-subfam = it1-subfam.

it1_xls-codcol = it1-codcol.

it1_xls-codcoat = it1-codcoat.

it1_xls-epaiscom = it1-epaiscom.

it1_xls-mcode = it1-mcode.

it1_xls-del_flag = it1-del_flag.

append it1_xls.

endloop.

call function 'DOWNLOAD'

exporting

filename = 'C:\'

filetype = 'DAT'

mode = 'X'

tables

data_tab = it1_xls

exceptions

invalid_filesize = 1

invalid_table_width = 2

invalid_type = 3

no_batch = 4

unknown_error = 5

gui_refuse_filetransfer = 6

others = 7.

clear it1_xls.

refresh it1_xls.

endif.

thanks,

Rajan

Read only

I355602
Product and Topic Expert
Product and Topic Expert
0 Likes
1,602

Hi,

Create a sub-screen with one parameter on it which can accept a value for file path.

Refer code:-

At screen logic:-


PROCESS BEFORE OUTPUT.
  MODULE status_8001.
  CALL SUBSCREEN sub_area1 INCLUDING V_PROG V_DYNNR.
PROCESS AFTER INPUT.
  MODULE USER_COMMAND_8001.
  MODULE INIT_SUBSCREEN.

In PAI,


MODULE INIT_SUBSCREEN.
  CASE sy-ucomm.
    WHEN 'DOWNLOAD' "funuction code for download buttons.
      V_PROG = sy-repid.
      V_DYNNR = '0800'. "sub-screen number
  ENDCASE.
ENDMODULE.

Now use the parameter on this sub-screen to accept the value for file path, and then use this path to download the data into the excel file at specified path.

Hope this helps you.

Thanks & Regards,

Tarun Gambhir

Read only

Former Member
0 Likes
1,602

Hi tarun

when i am using FM 'EXCEL_OLE_STANDARD_DAT' i am getting following dump

The current statement only supports character-type data objects.

Using this FM, we can download only character type fields.

i am getting this dump on RATE fielld

ragards

raadha

Read only

I355602
Product and Topic Expert
Product and Topic Expert
0 Likes
1,602

Hi

Try using:-


  CALL FUNCTION 'GUI_DOWNLOAD'
   EXPORTING
    FILENAME                        = 'C:/Vendors1.xls' "pass your path
    FILETYPE                        = 'DAT'
   TABLES
    DATA_TAB                        = ITAB "internal table
   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.

Hope this solves your problem.

Thanks & Regards,

Tarun Gambhir

Read only

Former Member
0 Likes
1,602

.