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: 

Repetition of header in ALV output once excel download is selected

Former Member
0 Kudos

Hi Experts,

I have alv report where I use FM as below

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

i_callback_program = w_repid

i_callback_top_of_page = 'TOP-OF-PAGE' "see FORM

is_layout = l_layout

it_fieldcat = lt_fieldcat

it_sort = l_sort

i_save = 'X'

TABLES

t_outtab = itab

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.

and top of page as below

FORM top-of-page.

* Title

w_header-typ = 'H'.

w_header-info = text-033.

APPEND w_header TO t_header.

CLEAR w_header.

* Report Name

w_header-typ = 'S'.

w_header-key = text-034.

w_header-info = sy-repid.

APPEND w_header TO t_header.

CLEAR w_header.

* Date

w_header-typ = 'S'.

w_header-key = text-035.

CONCATENATE sy-datum6(2) '.'+

sy-datum4(2) '.'+

sy-datum(4) INTO w_header-info.

APPEND w_header TO t_header.

CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

EXPORTING

it_list_commentary = t_header.

ENDFORM. "top-of-page

Its displaying well in output, but when I select excel download, the header is getting printed 4 times in the alv output and in the excel download it is printing twice. Please advise how to keep the header once. Note : I am not using any paging concept, simple header at the top.

Please advise.

Regards,

Kiran.

6 REPLIES 6

Former Member

Hi kiran,

While creating top-of-page,

You have to refresh your header internal table before populating it with data i.e,

FORM TOP.

Refresh IT_HEADER -->with this the header text will not get repeatedly printed

WA_HEADER-TYP = 'S'.

WA_HEADER-KEY = TEXT-001.

WA_HEADER-INFO = SY-REPID.

APPEND WA_HEADER TO IT_HEADER.

CLEAR WA_HEADER.

WA_HEADER-TYP = 'S'.

WA_HEADER-KEY = TEXT-002.

WA_HEADER-INFO = SY-UNAME.

APPEND WA_HEADER TO IT_HEADER.

CLEAR WA_HEADER.

WA_HEADER-TYP = 'S'.

WA_HEADER-KEY = TEXT-003.

WA_HEADER-INFO = SY-DATUM.

APPEND WA_HEADER TO IT_HEADER.

CLEAR WA_HEADER.

CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

EXPORTING

it_list_commentary = IT_HEADER

  • I_LOGO =

  • I_END_OF_LIST_GRID =

  • I_ALV_FORM =

.

ENDFORM.

Hope it helps you

Regards

Mansi

0 Kudos

yes, same problem is solved after adding refresh table IT_HEADER.

Former Member
0 Kudos

hi

see this,

sujeet2918
Active Contributor
0 Kudos

Hello Kiran,

you Clear your it_header.

it will work.

Have a Nice Day,

Regards,

Sujeet

Former Member
0 Kudos

Hi Mansi,

I tried adding refresh header.But still I am getting the same error. Please advise

FORM top-of-page.

refresh t_header. -


-


added

  • Title

w_header-typ = 'H'.

w_header-info = text-033.

APPEND w_header TO t_header.

CLEAR w_header.

  • Report Name

w_header-typ = 'S'.

w_header-key = text-034.

w_header-info = sy-repid.

APPEND w_header TO t_header.

CLEAR w_header.

  • Date

w_header-typ = 'S'.

w_header-key = text-035.

CONCATENATE sy-datum+6(2) '.'

sy-datum+4(2) '.'

sy-datum(4) INTO w_header-info.

APPEND w_header TO t_header.

CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

EXPORTING

it_list_commentary = t_header.

ENDFORM. "top-of-page

0 Kudos

Hi kiran,

I was also getting the header no. of times on the output screen ,

but after using refresh statement it got solved.

In your case due to which reason it is not getting solved cannot be make out without seeing the whole code.

Might your top-of-page perform statement is getting called more than once in your program.

Regrds

Mansi