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: 

Problem in downloading ALV output in excel

Former Member
0 Kudos

Dear Abapers,

I am facing a problem while downloading alv output in spreadsheet. Report headers and data headings are coming in excle but contents are missing instead of that No Data is displaying on excel sheet. I have debug that and observed the deep structure name T_OUTTAB using by the FM ALV_DATA_EXPORT is empty, It should contain the contents of my output data.

Below I am giving my code.

***********************************************declaration****************

BEGIN OF d_file_out,

index TYPE i, "Index no

msg TYPE string, "Message

msgtyp(1) TYPE c, "Message type

END OF d_file_out,

DATA:t_file_out TYPE TABLE OF d_file_out.

DATA:wa_file_out TYPE d_file_out.

**************************************************************************

  • Display Error Logs

PERFORM display_logs USING text-006.

*************************************************************************

FORM display_logs USING p_text TYPE string.

CONSTANTS: c_count TYPE char5 VALUE 'INDEX',

c_mestyp TYPE char6 VALUE 'MSG',

c_message TYPE char7 VALUE 'MSGTYP'.

*Field catalog

PERFORM: z_field_catalog USING c_count text-010, "Record number

z_field_catalog USING c_mestyp text-011, "Message type

z_field_catalog USING c_message text-012. "Message

*Top of page event

PERFORM z_event USING t_events.

  • wa_layout-colwidth_optimize = c_x.

  • ALV grid.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

  • i_buffer_active = 'X'

i_callback_program = sy-repid

  • is_layout = wa_layout

  • I_STRUCTURE_NAME = wa_file_out

it_fieldcat = t_field

it_events = t_events

TABLES

t_outtab = t_file_out

EXCEPTIONS

program_error = 1

OTHERS = 2.

IF sy-subrc <> 0.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

***********************************Fieldcatalog**********************************************

FORM z_field_catalog USING p_field TYPE any

p_name TYPE any.

wa_field-fieldname = p_field.

wa_field-seltext_l = p_name.

IF p_field = 'INDEX'.

wa_field-outputlen = '14'.

wa_field-col_pos = 1.

ELSEIF p_field = 'MSG'.

wa_field-outputlen = '120'.

wa_field-col_pos = 2.

ELSEIF p_field = 'MSGTYP'.

wa_field-outputlen = '08'.

wa_field-col_pos = 3.

ENDIF.

APPEND wa_field TO t_field.

CLEAR wa_field.

ENDFORM.

*********************************************************************

Here I have given my code, which contain the building of field catalog and Calling ALV Grid. I have already checked the excel micros settings. Other programs are working fine on my system and downloading in excel is also working.

Hope to get reply soon.

Regards,

Himanshu

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi.

Pls check out your field catalog attributes . FM REUSE_ALV_GRID_DISPLAY will cause such errors if some thing is wrong with field catalog attributes.

Cheers,

Shameeullak

3 REPLIES 3

Former Member
0 Kudos

Hi.

Pls check out your field catalog attributes . FM REUSE_ALV_GRID_DISPLAY will cause such errors if some thing is wrong with field catalog attributes.

Cheers,

Shameeullak

0 Kudos

Hi ,

use this to down load to xcel

v_file = lv_file.

DATA: BEGIN OF s_head OCCURS 0,

head(40) TYPE c ,

END OF s_head.

s_head-head = text-015."'Sales price'. * for header

APPEND s_head.

s_head-head = text-016."'Purchase price'. * for header

APPEND s_head.

s_head-head = text-017."'Listing Procedure'. * for header

APPEND s_head.

CALL FUNCTION 'GUI_DOWNLOAD'

EXPORTING

filename = v_file

filetype = 'ASC'

write_field_separator = '#'

TABLES

data_tab = it_output1[]

fieldnames = s_head[]

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.

Former Member
0 Kudos

Hi,

The code was perfect including field catalog.

Problem was in event top_of_page.Final internal table 't_file_out' is cleared after 'REUSE_ALV_COMMENTARY_WRITE', that's why the data was not coming in 'T_OUTTAB' i.e the table used in ALV_DATA_EXPORT FM.

Regards,

Himanshu