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: 

Downloading data from table

Former Member
0 Kudos

Hi Friends,

I want to download the data from the table. I am able to get by se11 but i want my header as the name of the filed not as text, can any one tell me how to download it in excel file with name of the field as header,

Regards,

Line

1 ACCEPTED SOLUTION

gopi_narendra
Active Contributor
0 Kudos

Hi Line,

While downloading data from SE11 or SE16 you have an option to chose the field headings to be the fieldnames or the field descriptions.

You can do this in the table contents output at

Settings --> User Parameters --> Field ( at keyword you have 2 radiobuttons)

Chose the radiobutton Field which will server your purpose.

If you want Field Text then chose that radiobutton.

Regards

Gopi

12 REPLIES 12

varma_narayana
Active Contributor
0 Kudos

Hi Lubin

In SE11 OR SE16 in the Selection Screen of Table entries :

Menu path:

Settings -> User Parameters

Here Select the Radiobutton FIELDNAME.

Now if u download you can see the fieldnames in Excel file.

<b>reward if helpful</b>

Former Member
0 Kudos

se11 0r se16

tool bar->local file or ctrlshiftf9)

popup display->select format download

gopi_narendra
Active Contributor
0 Kudos

Hi Line,

While downloading data from SE11 or SE16 you have an option to chose the field headings to be the fieldnames or the field descriptions.

You can do this in the table contents output at

Settings --> User Parameters --> Field ( at keyword you have 2 radiobuttons)

Chose the radiobutton Field which will server your purpose.

If you want Field Text then chose that radiobutton.

Regards

Gopi

former_member223537
Active Contributor
0 Kudos

Hi,

Use the following program to Download/Upload any table contents.

REPORT zupload_download NO STANDARD PAGE HEADING MESSAGE-ID saplwosa .

*=======================================================================

  • Variables

*=======================================================================

DATA descr_struct_ref TYPE REF TO cl_abap_structdescr.

DATA wa_fcat TYPE lvc_s_fcat.

DATA: it_fieldcatalog TYPE lvc_t_fcat.

DATA: dataref TYPE REF TO data.

DATA: one LIKE pcfile-drive,

two LIKE pcfile-path,

long TYPE i,

flag TYPE c,

filepath(128) TYPE c,

file_tab TYPE string,

tabname LIKE dd02l-tabname.

*=======================================================================

  • Field-Symbols.

*=======================================================================

FIELD-SYMBOLS:

<row> TYPE ANY TABLE,

<table> TYPE STANDARD TABLE,

<component> TYPE abap_compdescr,

<fs> TYPE ANY.

*=======================================================================

  • Selection screen

*=======================================================================

SELECTION-SCREEN BEGIN OF BLOCK data WITH FRAME TITLE text-t01.

PARAMETERS:

tabnam(128) TYPE c,

function(1) TYPE c OBLIGATORY DEFAULT 'D',

listname LIKE rlgrap-filename.

SELECTION-SCREEN END OF BLOCK data.

*=======================================================================

  • At Selection screen

*=======================================================================

AT SELECTION-SCREEN ON VALUE-REQUEST FOR listname.

PERFORM get_filename CHANGING listname.

*=======================================================================

  • Start-of-selection

*=======================================================================

START-OF-SELECTION.

IF tabnam(1) NE 'Z'.

MESSAGE i999(zfe01) WITH 'Only Z tables allowed'.

LEAVE PROGRAM.

ENDIF.

CLEAR flag.

  • PERFORM LOAD_DATA USING TABNAM.

PERFORM verify_table USING tabnam CHANGING flag.

IF flag NE 'X'.

IF function EQ 'D'.

PERFORM create_table USING tabnam.

PERFORM download_table USING tabnam.

ELSE.

PERFORM create_table USING tabnam.

PERFORM upload_table USING tabnam.

ENDIF.

ELSE.

MESSAGE s000 WITH 'The proposed table doesn''t exist.'.

ENDIF.

----


  • FORM GET_FILENAME *

----


  • Name of the directory.

----


FORM get_filename CHANGING listname.

CALL FUNCTION 'WS_FILENAME_GET'

EXPORTING

def_filename = listname

def_path = 'C:\downloads\list'

mask = ',.,.. '

mode = 'S'

title = 'Save as'

IMPORTING

filename = listname

EXCEPTIONS

inv_winsys = 1

no_batch = 2

selection_cancel = 3

selection_error = 4

OTHERS = 5.

ENDFORM. "get_filename

----


  • FORM LOAD_DATA *

----


  • Specifies the path and table name

----


FORM load_data USING my_tab.

DATA: w_file LIKE pcfile-path.

w_file = listname.

CALL FUNCTION 'PC_SPLIT_COMPLETE_FILENAME'

EXPORTING

complete_filename = w_file

IMPORTING

drive = one

path = two

EXCEPTIONS

invalid_drive = 1

invalid_extension = 2

invalid_name = 3

invalid_path = 4

OTHERS = 5.

CONCATENATE one ':' two INTO filepath.

CONCATENATE filepath my_tab '.txt' INTO file_tab.

ENDFORM. "load_data

----


  • FORM DOWNLOAD_TABLE *

----


  • Downloads the table data.

----


FORM download_table USING my_tab.

file_tab = listname.

SELECT *

INTO TABLE <row>

FROM (my_tab).

ASSIGN <row> TO <table>.

CALL FUNCTION 'GUI_DOWNLOAD'

EXPORTING

filename = file_tab

filetype = 'ASC'

write_field_separator = 'X'

TABLES

data_tab = <table>

EXCEPTIONS

file_write_error = 1

no_batch = 2

gui_refuse_filetransfer = 3

invalid_type = 4

no_authority = 5

unknown_error = 6.

IF sy-subrc EQ 0.

CALL FUNCTION 'POPUP_TO_INFORM'

EXPORTING

titel = 'Successful Download'

txt1 = 'All the data from the table'

txt2 = 'was correctly downloaded.'.

ELSE.

CALL FUNCTION 'POPUP_TO_INFORM'

EXPORTING

titel = 'Download Error!'

txt1 = 'The data of the table'

txt2 = 'couldn''t be downloaded.'.

ENDIF.

ENDFORM. "download_table

----


  • FORM UPLOAD_TABLE *

----


  • Table Upload.

----


FORM upload_table USING my_tab.

file_tab = listname.

ASSIGN <row> TO <table>.

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

filename = file_tab

filetype = 'ASC'

has_field_separator = 'X'

IMPORTING

filelength = long

TABLES

data_tab = <table>

EXCEPTIONS

file_open_error = 1

file_read_error = 2

no_batch = 3

gui_refuse_filetransfer = 4

invalid_type = 5

no_authority = 6

unknown_error = 7.

DATA : l_charg(10) TYPE n,

l_charg_char(10) TYPE c,

l_date(8),

l_time(6),

l_dd(2),

l_mm(2),

l_yyyy(4),

l_hh(2),

l_min(2),

l_sec(2).

FIELD-SYMBOLS: <wa_table> TYPE ANY,

<value> TYPE ANY.

LOOP AT <table> ASSIGNING <wa_table>.

ASSIGN COMPONENT 'CHARG' OF STRUCTURE <wa_table> TO <value>.

IF sy-subrc = 0.

l_charg_char = <value>.

SHIFT l_charg_char RIGHT DELETING TRAILING space.

IF l_charg_char+0(1) EQ space AND

l_charg_char+0(2) NE space.

MOVE <value> TO l_charg.

MOVE l_charg TO <value>.

ENDIF.

ENDIF.

ASSIGN COMPONENT 'MANDT' OF STRUCTURE <wa_table> TO <value>.

IF sy-subrc = 0.

<value> = sy-mandt.

ENDIF.

  • DO.

  • ASSIGN COMPONENT sy-index OF STRUCTURE <wa_table>

  • TO <VALUE>.

  • IF sy-subrc NE 0.

  • EXIT.

  • ENDIF.

  • IF <VALUE> CA '/'.

  • SPLIT <VALUE> AT '/'

  • INTO l_mm

  • l_dd

  • l_yyyy.

  • CONCATENATE l_yyyy l_mm l_dd

  • INTO <VALUE>.

*

  • ENDIF.

  • IF <VALUE> CA ':'.

  • SPLIT <VALUE> AT ':'

  • INTO l_hh

  • l_min

  • l_sec.

  • CONCATENATE l_hh l_min l_sec

  • INTO <VALUE>.

*

  • ENDIF.

  • ENDDO.

ENDLOOP.

MODIFY (my_tab) FROM TABLE <table>.

IF sy-subrc EQ 0.

CALL FUNCTION 'POPUP_TO_INFORM'

EXPORTING

titel = 'Successful Upload'

txt1 = 'All the data from the table'

txt2 = 'was correctly uploaded.'.

ELSE.

CALL FUNCTION 'POPUP_TO_INFORM'

EXPORTING

titel = 'Upload Error!'

txt1 = 'The data of the table'

txt2 = 'couldn''t be uploaded.'.

ENDIF.

ENDFORM. "upload_table

----


  • FORM CREATE_TABLE *

----


  • Creates a dynamic internal table.

----


FORM create_table USING my_tab.

CREATE DATA dataref TYPE (my_tab).

ASSIGN dataref->* TO <fs>.

descr_struct_ref ?= cl_abap_typedescr=>describe_by_data( <fs> ).

LOOP AT descr_struct_ref->components ASSIGNING <component>.

wa_fcat-fieldname = <component>-name.

wa_fcat-ref_table = my_tab.

wa_fcat-ref_field = <component>-name.

APPEND wa_fcat TO it_fieldcatalog.

CLEAR wa_fcat.

ENDLOOP.

CALL METHOD cl_alv_table_create=>create_dynamic_table

EXPORTING

it_fieldcatalog = it_fieldcatalog

IMPORTING

ep_table = dataref

EXCEPTIONS

generate_subpool_dir_full = 1

OTHERS = 2.

ASSIGN dataref->* TO <row>.

ENDFORM. "create_table

&----


*& Form VERIFY_TABLE

&----


  • The table must exist!

----


FORM verify_table USING tabnam CHANGING flag.

SELECT SINGLE tabname

INTO (tabname)

FROM dd02l

WHERE tabname EQ tabnam.

IF sy-subrc NE 0.

flag = 'X'.

ENDIF.

ENDFORM. "verify_table

Best regards,

Prashant

0 Kudos

Hi,

This program download all the data from the table ?

I am getting error at line 298 'Exception generate_subpool_dir_full = 1' does not exist.

Regards,

Line

0 Kudos

Hi Prashant,

This program download all the data from the table ?

I am getting error at line 298 'Exception generate_subpool_dir_full = 1' does not exist.

Regards,

Line

0 Kudos

I Prashantj patil,

I tried to use your code but i am getting error exception does not exist, Can you tell me what shall i do to run the program.

Regards,

Line

Former Member
0 Kudos

Hi Line ,

Goto Se11 Tcode give the table name and display

click contents then press F8...

Goto menu bar click on setting after that click the sub fields user parameters select ALV list Radiobuttom in state of Se11 standard lis the press continue , Now u can downlaod the data in Excel Format .

Regards,

Nihar Swain

former_member223537
Active Contributor
0 Kudos

Hi,

Yes it downloads all the data from the table.

Save it in a TXT file if Excel file cant store all the records bcz of limitations of number of rows.

Best regards,

Prashant

0 Kudos

Hi Prashant,

But I am getting error at line 298 'Exception generate_subpool_dir_full = 1' does not exist. Can you just tell me how to correct the error.

Regards,

Line

former_member223537
Active Contributor
0 Kudos

Hi,

I am assuming that you are getting a runtime error & not activation error.

If so, then please provide some other path to download the data & retry.

Best regards,

Prashant

0 Kudos

Hi prashant,

Thanx for your reply.

No I am getting activation error as 'exception "generate_subpool_dir_full" doest not exist" not the runtime error.

Can you please tell me what could be the error.

Regards,

Line