Skip to Content

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

Header not printed in ALV

Hi Gurus,

Here is my code. The Header in the ALV is not printed. Please have a look at my code.

TYPE-POOLS slis.

TYPES: BEGIN OF t_maramakt,

matnr LIKE makt-matnr,

spras LIKE makt-spras,

maktx LIKE makt-maktx,

mtart LIKE mara-mtart,

matkl LIKE mara-matkl,

ersda LIKE mara-ersda,

ernam LIKE mara-ernam,

END OF t_maramakt.

TABLES: mara, makt.

DATA: i_maramakt TYPE STANDARD TABLE OF t_maramakt INITIAL SIZE 10

WITH HEADER LINE,

v_layout TYPE slis_layout_alv,

v_repid LIKE sy-repid,

v_fieldcat2 TYPE slis_t_fieldcat_alv,

v_fieldcat TYPE slis_fieldcat_alv.

INITIALIZATION.

REFRESH: i_maramakt.

CLEAR: v_layout, v_repid, v_fieldcat, v_fieldcat2.

START-OF-SELECTION.

SELECT makt~matnr spras maktx mtart matkl ersda ernam

INTO TABLE i_maramakt

FROM makt

INNER JOIN mara ON ( maktmatnr = maramatnr )

UP TO 10 ROWS.

IF sy-subrc = 0.

ENDIF.

  • SORTS THE TABLE BY MATERIAL NUMBER*

SORT i_maramakt BY matnr ASCENDING.

  • CALLS F_BUILD_FIELD_CATALOG FORM*

PERFORM f_build_field_catalog.

  • CALLS F_BUILD_LAYOUT*

PERFORM f_build_layout.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

I_CALLBACK_PROGRAM = v_repid

I_CALLBACK_TOP_OF_PAGE = 'f_top_of_page'

IS_LAYOUT = v_layout

IT_FIELDCAT = v_fieldcat2

I_SAVE = 'X'

TABLES

t_outtab = i_maramakt

EXCEPTIONS

PROGRAM_ERROR = 1

OTHERS = 2.

CASE sy-subrc.

WHEN 1.

WRITE: / 'Program Error'(019).

WHEN 2.

WRITE: / 'Others'(020).

WHEN OTHERS.

ENDCASE.

END-OF-SELECTION.

CREATE FORM BUILD_FIELD_CATALOG

FORM f_build_field_catalog.

PERFORM f_build_table USING:

'MATNR'(010) 'MAKT'(017) 'MATNR'(010) 'MaterialNumber'(003),

'SPRAS'(011) 'MAKT'(017) 'SPRAS'(011) 'LanguageKey'(004),

'MAKTX'(012) 'MAKT'(017) 'MAKTX'(012) 'MaterialDescription'(005),

'MTART'(013) 'MARA'(018) 'MTART'(013) 'MaterialType'(006),

'MATKL'(014) 'MARA'(018) 'MATKL'(014) 'MaterialGroup'(007),

'ERSDA'(015) 'MARA'(018) 'ERSDA'(015) 'CreationDate'(008),

'ERNAM'(016) 'MARA'(018) 'ERNAM'(016) 'NameofPerson'(009).

ENDFORM. "F_BUILD_FIELD_CATALOG

CREATED FORM BUILD_TABLE

FORM f_build_table USING: p_fieldname p_tabname p_reffield p_fieldtext.

CLEAR v_fieldcat.

v_fieldcat-fieldname = p_fieldname.

v_fieldcat-seltext_l = p_fieldtext.

v_fieldcat-ref_tabname = p_tabname.

v_fieldcat-ref_fieldname = p_reffield.

APPEND v_fieldcat TO v_fieldcat2.

ENDFORM. "F_BUILD_TABLE

CREATED FORM BUILD_LAYOUT

FORM f_build_layout.

CLEAR v_layout.

v_layout-no_input = 'X'(002).

v_layout-colwidth_optimize = 'X'(002).

  • v_layout-window_titlebar = sy-title.

v_layout-header_text = 'header'.

ENDFORM. "F_BUILD_LAYOUT

FORM f_top_of_page.

DATA: t_header TYPE slis_t_listheader,

wa_header TYPE slis_listheader.

wa_header-typ = 'H'.

wa_header-info = 'Trial lang to'.

APPEND wa_header TO t_header.

CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

EXPORTING

it_list_commentary = t_header.

clear t_header.

ENDFORM. "top-of-page

Thanks.

Benedict

Tags:
Not what you were looking for? View more on this topic or Ask a question