Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

ALV header not showing in display

Hello experts,

This problem has been bugging me for quite some time. I modified a report to be shown in ALV format. Now, when I execute the report the header does not display. Anyway, I have pasted below my code so you guys might see if I'm missing something. Help would be greatly appreciated. Thanks guys and have a nice day!

FORM display_alv.

PERFORM f_build_comment USING gt_list_top_of_page[].

PERFORM f_build_layout USING gs_layout.

PERFORM f_init_fieldcat USING gt_fieldcat[].

PERFORM f_init_events USING 'TOP' gt_events[].

CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_INIT'

EXPORTING

i_callback_program = g_repid

i_callback_user_command = 'USER_COMMAND'.

CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'

EXPORTING

it_fieldcat = gt_fieldcat[]

is_layout = gs_layout

i_tabname = 'IT_ZTS0001'

it_events = gt_events[]

it_sort = gt_sort_del

i_text = '1ST'

TABLES

t_outtab = it_zts0001.

gt_print-reserve_lines = 2.

gt_print-no_coverpage = 'X'.

CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_DISPLAY'

EXPORTING

is_print = gt_print.

ENDFORM. " DISPLAY_ALV

----


  • FORM f_build_comment *

----


  • ........ *

----


  • --> %TOP_OF_PAGE *

----


FORM f_build_comment USING %top_of_page TYPE slis_t_listheader.

DATA: ls_line TYPE slis_listheader,

d_name(60),

lv_date(10),

lv_time(10),

lc_dttm(50).

**-REPORT NAME

CLEAR: d_name, ls_line.

MOVE: sy-title TO d_name.

ls_line-typ = 'H'.

ls_line-info = d_name.

APPEND ls_line TO %top_of_page.

**-USER ID AND DATE/TIME

CLEAR: d_name, ls_line.

CONCATENATE: 'Generated by:' sy-uname INTO d_name SEPARATED BY space.

ls_line-typ = 'H'.

ls_line-info = d_name.

APPEND ls_line TO %top_of_page.

CLEAR: d_name, ls_line.

WRITE: sy-datum TO lv_date MM/DD/YYYY,

sy-uzeit TO lv_time USING EDIT MASK '__:__:__'.

CONCATENATE: 'Generated on:' lv_date lv_time

INTO d_name SEPARATED BY space.

ls_line-typ = 'H'.

ls_line-info = d_name.

APPEND ls_line TO %top_of_page.

ENDFORM. " F_BUILD_COMMENT

----


  • FORM f_build_layout *

----


  • ........ *

----


  • --> %LAYOUT *

----


FORM f_build_layout USING %layout TYPE slis_layout_alv.

%layout-zebra = 'X'.

ENDFORM. " F_BUILD_LAYOUT

----


  • FORM f_init_fieldcat *

----


  • ........ *

----


  • --> %FIELDCAT *

----


FORM f_init_fieldcat USING %fieldcat TYPE slis_t_fieldcat_alv.

DATA: lc_fieldcat TYPE slis_fieldcat_alv.

CLEAR lc_fieldcat.

DEFINE m_field.

add 1 to lc_fieldcat-col_pos.

lc_fieldcat-fieldname = &1.

lc_fieldcat-outputlen = &2.

lc_fieldcat-seltext_l = &3.

lc_fieldcat-do_sum = &4.

lc_fieldcat-inttype = &5.

lc_fieldcat-hotspot = &6.

lc_fieldcat-fix_column = &7.

lc_fieldcat-ddictxt = 'L'.

lc_fieldcat-no_zero = 'X'.

append lc_fieldcat to %fieldcat.

END-OF-DEFINITION.

m_field 'KUNNR' '12' 'Customer Number' '' '' '' ''.

m_field 'CD_SEQ' '12' 'Code' '' '' '' ''.

m_field 'ZADDRESS' '12' 'Address' '' '' '' ''.

m_field 'ZCPERSON' '12' 'Contact Person' '' '' '' ''.

m_field 'ZCNUMBER' '12' 'Contact Number' '' '' '' ''.

ENDFORM. " f_init_fieldcat

----


  • FORM f_init_events *

----


  • ........ *

----


  • --> P_TYPE *

  • --> %EVENTS *

----


FORM f_init_events USING p_type CHANGING %events TYPE slis_t_event.

CALL FUNCTION 'REUSE_ALV_EVENTS_GET'

EXPORTING

i_list_type = 0

IMPORTING

et_events = %events

EXCEPTIONS

list_type_wrong = 1

OTHERS = 2.

IF sy-subrc = 0.

PERFORM f_build_events USING: slis_ev_user_command.

IF p_type = 'TOP'.

PERFORM f_build_events USING: gc_top.

  • ELSEIF p_type = 'SUM'.

  • PERFORM f_build_events_sum USING: gc_topsum.

ENDIF.

ELSE.

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

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

ENDIF.

ENDFORM. " F_INIT_EVENTS

----


  • FORM f_build_events *

----


  • ........ *

----


  • --> %EVENT *

----


FORM f_build_events USING %event.

READ TABLE gt_events WITH KEY name = %event.

IF sy-subrc = 0.

MOVE: %event TO gt_events-form.

  • MOVE 'USER_COMMAND' TO gt_events-form.

MODIFY gt_events INDEX sy-tabix.

ENDIF.

ENDFORM. " F_BUILD_EVENTS

----


  • FORM top_of_page *

----


  • ........ *

----


FORM top_of_page.

CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

EXPORTING

it_list_commentary = gt_list_top_of_page.

ENDFORM.

Tags:
Former Member
Former Member replied

Hi,

Using ALV_BLOCK you can append multiple internal table and display them in one shot.

With ALV Grid you cannot do that, but the output is more prettier than a list. It will look a excel sheet.

Look at the layout values you are passing for the size of the ALV.

Regards,

Ravi

Note : Please mark the helpful answers

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question