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: 

Header not printed in ALV

Former Member
0 Kudos

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

8 REPLIES 8

former_member497886
Participant
0 Kudos

hi,

Ur code is

CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

EXPORTING

it_list_commentary = t_header.

It should be

CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

EXPORTING

it_list_commentary = t_header[].

Hope it helps u.

All the best,

Mohammadi.

0 Kudos

Hi Mohammadi,

Thanks for your immediate reply. But still, it does not show the header portion.

Anyone?

Benedict

Former Member
0 Kudos

hey choa

do one thing in FM

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.

when you are passing I_CALLBACK_TOP_OF_PAGE = 'f_top_of_page' pass it in CAPS as

I_CALLBACK_TOP_OF_PAGE = 'F_TOP_OF_PAGE'

it will work fine

~hitesh

0 Kudos

Hi Hitesh,

Still not working.

Thanks.

Benedict

Former Member
0 Kudos

hi...

top-of-page must be tiggered...

refer this link

and refer this code..

kiran_k8
Active Contributor
0 Kudos

Ben,

Instead of that you try like this

data : title type lvc_title.

field-symbols <fs> type LVC_TITLE.

concatenate 'Trial lang to' ' ' into title separated by space.

assign title to <fs>.

In the

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

I_GRID_TITLE = <fs>

K.Kiran.

Former Member
0 Kudos

Hi Kiran,

It created a title of the table. What we need is a header for the ALV.

Thanks.

Anyone?

Benedict

Former Member
0 Kudos

solved. v_repid is null.

Thanks to all.