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: 

ALV Grid Header Problem.

Former Member
0 Kudos
234

Hi All,

I want to display the header of the ALV Grid as:

Material 111/11823

Plant/Usage/Alt 2845/3/5

Description ABI CAB

Base Qty. 23.000

The values are to be taken from variables

Please suggest how to do this.

Thanks

1 ACCEPTED SOLUTION

Former Member
0 Kudos
187

Hi,

in GRID use this:

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

...

I_CALLBACK_TOP_OF_PAGE = <b>'TOP_OF_PAGE_GRID'</b>

...

<b>FORM TOP_OF_PAGE_GRID.</b>

*

DATA: LS_LINE TYPE SLIS_LISTHEADER.

*

REFRESH GT_LIST_TOP_OF_PAGE.

*

LS_LINE-TYP = 'H'.

LS_LINE-INFO = SY-TITLE.

APPEND LS_LINE TO GT_LIST_TOP_OF_PAGE.

*

CLEAR LS_LINE.

LS_LINE-TYP = 'S'.

LS_LINE-KEY = 'Datum'.

WRITE SY-DATUM TO LS_LINE-INFO DD/MM/YYYY.

APPEND LS_LINE TO GT_LIST_TOP_OF_PAGE.

*

CLEAR LS_LINE.

LS_LINE-TYP = 'S'.

LS_LINE-KEY = 'Report'.

WRITE SY-REPID TO LS_LINE-INFO.

APPEND LS_LINE TO GT_LIST_TOP_OF_PAGE.

*

CLEAR LS_LINE.

LS_LINE-TYP = 'S'.

LS_LINE-KEY = 'Benutzer'.

WRITE SY-UNAME TO LS_LINE-INFO.

APPEND LS_LINE TO GT_LIST_TOP_OF_PAGE.

*

CLEAR LS_LINE.

LS_LINE-TYP = 'S'.

APPEND LS_LINE TO GT_LIST_TOP_OF_PAGE.

*

  • LS_LINE-TYP = 'A'.

  • LS_LINE-INFO = 'A - Zeile der Ausgabe'.

  • APPEND LS_LINE TO GT_LIST_TOP_OF_PAGE.

*

CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

EXPORTING

  • I_LOGO = 'ENJOYSAP_LOGO'

IT_LIST_COMMENTARY = GT_LIST_TOP_OF_PAGE.

*

ENDFORM.

Hope it helps.

Regards, Dieter

11 REPLIES 11

Former Member
0 Kudos
187

use event TOP-OF-PAGE.

Former Member
0 Kudos
187

Hi

U can use fm REUSE_ALV_COMMENTARY_WRITE

Max

Former Member
0 Kudos
187

sorry , check MAXI post.

Message was edited by:

Prabhu Peram

Former Member
0 Kudos
187

Hi,

write a form which calls the top-of-page, in which call reuse_alv_commentary_write and populate the list header of type slis_t_listheader with the structure slis_s_listheader.

populate list header table as follows

typ = H or S or A

key = field name

info-= variable name to list header.

Former Member
0 Kudos
188

Hi,

in GRID use this:

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

...

I_CALLBACK_TOP_OF_PAGE = <b>'TOP_OF_PAGE_GRID'</b>

...

<b>FORM TOP_OF_PAGE_GRID.</b>

*

DATA: LS_LINE TYPE SLIS_LISTHEADER.

*

REFRESH GT_LIST_TOP_OF_PAGE.

*

LS_LINE-TYP = 'H'.

LS_LINE-INFO = SY-TITLE.

APPEND LS_LINE TO GT_LIST_TOP_OF_PAGE.

*

CLEAR LS_LINE.

LS_LINE-TYP = 'S'.

LS_LINE-KEY = 'Datum'.

WRITE SY-DATUM TO LS_LINE-INFO DD/MM/YYYY.

APPEND LS_LINE TO GT_LIST_TOP_OF_PAGE.

*

CLEAR LS_LINE.

LS_LINE-TYP = 'S'.

LS_LINE-KEY = 'Report'.

WRITE SY-REPID TO LS_LINE-INFO.

APPEND LS_LINE TO GT_LIST_TOP_OF_PAGE.

*

CLEAR LS_LINE.

LS_LINE-TYP = 'S'.

LS_LINE-KEY = 'Benutzer'.

WRITE SY-UNAME TO LS_LINE-INFO.

APPEND LS_LINE TO GT_LIST_TOP_OF_PAGE.

*

CLEAR LS_LINE.

LS_LINE-TYP = 'S'.

APPEND LS_LINE TO GT_LIST_TOP_OF_PAGE.

*

  • LS_LINE-TYP = 'A'.

  • LS_LINE-INFO = 'A - Zeile der Ausgabe'.

  • APPEND LS_LINE TO GT_LIST_TOP_OF_PAGE.

*

CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

EXPORTING

  • I_LOGO = 'ENJOYSAP_LOGO'

IT_LIST_COMMENTARY = GT_LIST_TOP_OF_PAGE.

*

ENDFORM.

Hope it helps.

Regards, Dieter

Former Member
0 Kudos
187

hi rahul...

<b>declarations</b>

CONSTANTS : gc_formname_top_of_page TYPE slis_formname VALUE

'TOP_OF_PAGE'.

data : it_list_top_of_page TYPE slis_t_listheader,

it_events TYPE slis_t_event,

wa_line TYPE slis_listheader,

lit_alv_event TYPE slis_alv_event.

PERFORM eventtab_build USING it_events[].

PERFORM list_header USING it_list_top_of_page[].

PERFORM top_of_page.

PERFORM f016_grid_function_module. "FUNCTION MODULE TO DISPLAY ALV

"GRID

FORM list_header USING lt_top_of_page TYPE slis_t_listheader.

CLEAR wa_line.

wa_line-typ = text-091 . "H

wa_line-info = text-065 . "material 111/11823

APPEND wa_line TO lt_top_of_page.

CLEAR wa_line.

wa_line-typ = text-091 . "H

wa_line-info = text-066 . "plant/usage/alt 2845/3/5

APPEND wa_line TO lt_top_of_page.

CLEAR wa_line.

wa_line-typ = text-091 . "H

wa_line-info = text-067. "description abi cab

APPEND wa_line TO lt_top_of_page.

CLEAR wa_line.

wa_line-typ = text-092 . "h

wa_line-info = text-106 . "Base Qty. 23.000

APPEND wa_line TO lt_top_of_page.

CLEAR wa_line.

ENDFORM.

FORM top_of_page.

*USING REUSE_ALV_COMMMENTARY_WRITE FOR WRITING THE TOP OF PAGE

CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

EXPORTING

it_list_commentary = it_list_top_of_page.

ENDFORM. "TOP_OF_PAGE

FORM f016_grid_function_module.

*USING REUSE_ALV_GRID_DISPLAY FOR DISPLAYING THE GRID.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

i_callback_program = sy-repid

it_events = it_events[]

TABLES

t_outtab = it_ageing -


internal table to be passed for grid display......

EXCEPTIONS

program_error = lc_1

OTHERS = lc_2.

*IF SY-SUBRC IS SUCCESS.

IF sy-subrc <> lc_0.

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

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

*ENDIF SY-SUBRC IS SUCCESS.

ENDIF.

ENDFORM. "f016_grid_function_module

Former Member
0 Kudos
187

Hi,

Use top of page.Here are the steps for top of page:

  • work area and internal table for top of page.

DATA: it_list_top_of_page TYPE slis_t_listheader,

it_events TYPE slis_t_event,

gs_layout TYPE slis_layout_alv,

lwa_line TYPE slis_listheader.

  • constant to store top of page

CONSTANTS: gc_formname_top_of_page TYPE slis_formname VALUE 'TOP_OF_PAGE'.

PERFORM eventtab_build USING it_events[].

PERFORM list_header USING it_list_top_of_page[].

PERFORM layout_build USING gs_layout.

PERFORM display.

FORM eventtab_build USING lit_events TYPE slis_t_event.

DATA: lit_alv_event TYPE slis_alv_event.

CALL FUNCTION 'REUSE_ALV_EVENTS_GET'

EXPORTING

i_list_type = 0

IMPORTING

et_events = lit_events.

READ TABLE lit_events WITH KEY name = slis_ev_top_of_page

INTO lit_alv_event.

IF sy-subrc = 0.

MOVE gc_formname_top_of_page TO lit_alv_event-form.

APPEND lit_alv_event TO lit_events.

ENDIF.

ENDFORM. "EVENTTAB_BUILD

FORM list_header USING lt_top_of_page TYPE slis_t_listheader.

CLEAR lwa_line.

lwa_line-typ = 'S'.

lwa_line-key = description for field.

lwa_line-info = <field name or date ot time, etc> .

APPEND lwa_line TO lt_top_of_page.

lwa_line-key = description for field.

lwa_line-info = <field name or date ot time, etc>.

APPEND lwa_line TO lt_top_of_page.

CLEAR lwa_line.

lwa_line-typ = 'S'.

lwa_line-key = description for field.

lwa_line-info = sy-datum.

APPEND lwa_line TO lt_top_of_page.

CLEAR lwa_line.

lwa_line-typ = 'S'.

lwa_line-key = description for field.

lwa_line-info = sy-uname.

APPEND lwa_line TO lt_top_of_page.

ENDFORM. "COMMENT_BUILD

FORM top_of_page.

CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

EXPORTING

it_list_commentary = it_list_top_of_page.

ENDFORM. "TOP_OF_PAGE

&----


*& Form LAYOUT_BUILD

&----


----


  • -->LS_LAYOUT for zebra pattern between records

----


FORM layout_build USING ls_layout TYPE slis_layout_alv.

ls_layout-zebra = 'X'.

ENDFORM. "LAYOUT_BUILD

&----


*& Form display

&----


  • text

----


FORM display.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

i_callback_program = sy-repid

is_layout = gs_layout

it_fieldcat = it_fieldcat

it_events = it_events[]

TABLES

t_outtab = lit_field

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.

ENDFORM. "display

even zebra pattern is also included in this.

Former Member
0 Kudos
187

Hi,

Below is the sample code to get the date/time/username

the same way we fill in the gt_list_top_of_page with the variables ...

write: sy-datum to v_date,

sy-uzeit to v_time.

concatenate 'Run By/Date/Time:' sy-uname '/' v_date '/' v_time into v_head_desc separated by space.

gr_line-typ = 'S'.

gr_line-info = v_head_desc.

append gr_line to gt_list_top_of_page.

clear gr_line.

call function 'REUSE_ALV_COMMENTARY_WRITE'

exporting it_list_commentary = gt_list_top_of_page.

Please reward points if useful...

Raji

Former Member
0 Kudos
187

Hi,

Refer this demo program:

SALV_FORM_DEMO_LAYOUTS

The subroutines for TOP-OF_PAGE event are:

Form set_slis_events

Form handle_top_of_page.

Also refer the following Code:

-


Data declaration

-


.

FIELD-SYMBOLS: <ls_event> TYPE slis_alv_event.

DATA: cr_content TYPE REF TO cl_salv_form_element,

gt_evts TYPE slis_t_event.

DATA: lr_grid TYPE REF TO cl_salv_form_layout_grid,

lr_flow TYPE REF TO cl_salv_form_layout_flow,

lr_label TYPE REF TO cl_salv_form_label,

lr_text TYPE REF TO cl_salv_form_text.

-


To get Events

-


CALL FUNCTION 'REUSE_ALV_EVENTS_GET'

EXPORTING

i_list_type = 4

IMPORTING

et_events = gt_evts

EXCEPTIONS

list_type_wrong = 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.

*Fetch only TOP_OF_PAGE event

DELETE gt_evts WHERE name NE 'TOP_OF_PAGE'.

*

*Call event.

LOOP AT gt_evts ASSIGNING <ls_event>.

CONCATENATE 'HANDLE_' <ls_event>-name INTO <ls_event>-form.

ENDLOOP.

-


Display Grid

-


CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

i_callback_program = sy-repid

it_fieldcat = gt_fieldcat

it_sort = gt_sort

it_events = gt_evts

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.

-


" Dynamic call no need to write "perform HANDLE_TOP_OF_PAGE"

-


FORM HANDLE_TOP_OF_PAGE.

*... a grid is created

CREATE OBJECT lr_grid.

*... in the cell [1,1] flow information is set

lr_flow = lr_grid->create_flow(

row = 1

column = 1 ).

lr_label = lr_flow->create_label( text = text-t01 ).

*Give the name of the field to be displayed eg. "itab-rec_num"

lr_text = lr_flow->create_text( text = itab-rec_num ).

lr_label->set_label_for( lr_text ).

cr_content = lr_grid.

cl_salv_form_content=>set( cr_content ).

Former Member
0 Kudos
187

&----


*& Report ZDEMO_ALVGRID *

*& *

&----


*& *

*& Example of a simple ALV Grid Report with grand total *

*& ................................... *

*& *

*& The basic requirement for this demo is to display a number of *

*& fields from the EKKO table. *

&----


REPORT zdemo_alvgrid .

TABLES: ekko.

type-pools: slis. "ALV Declarations

*Data Declaration

*----


TYPES: BEGIN OF t_ekko,

ebeln TYPE ekpo-ebeln,

ebelp TYPE ekpo-ebelp,

statu TYPE ekpo-statu,

aedat TYPE ekpo-aedat,

matnr TYPE ekpo-matnr,

menge TYPE ekpo-menge,

meins TYPE ekpo-meins,

netpr TYPE ekpo-netpr,

peinh TYPE ekpo-peinh,

END OF t_ekko.

DATA: it_ekko TYPE STANDARD TABLE OF t_ekko INITIAL SIZE 0,

wa_ekko TYPE t_ekko.

*ALV data declarations

data: fieldcatalog type slis_t_fieldcat_alv with header line,

gd_tab_group type slis_t_sp_group_alv,

gd_layout type slis_layout_alv,

gd_repid like sy-repid.

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

*Start-of-selection.

START-OF-SELECTION.

perform data_retrieval.

perform build_fieldcatalog.

perform build_layout.

perform display_alv_report.

perform top-of-page.

&----


*& Form BUILD_FIELDCATALOG

&----


  • Build Fieldcatalog for ALV Report

----


form build_fieldcatalog.

  • There are a number of ways to create a fieldcat.

  • For the purpose of this example i will build the fieldcatalog manualy

  • by populating the internal table fields individually and then

  • appending the rows. This method can be the most time consuming but can

  • also allow you more control of the final product.

  • Beware though, you need to ensure that all fields required are

  • populated. When using some of functionality available via ALV, such as

  • total. You may need to provide more information than if you were

  • simply displaying the result

  • I.e. Field type may be required in-order for

  • the 'TOTAL' function to work.

fieldcatalog-fieldname = 'EBELN'.

fieldcatalog-seltext_m = 'Purchase Order'.

fieldcatalog-col_pos = 0.

fieldcatalog-outputlen = 10.

fieldcatalog-emphasize = 'X'.

fieldcatalog-key = 'X'.

  • fieldcatalog-do_sum = 'X'.

  • fieldcatalog-no_zero = 'X'.

append fieldcatalog to fieldcatalog.

clear fieldcatalog.

fieldcatalog-fieldname = 'EBELP'.

fieldcatalog-seltext_m = 'PO Item'.

fieldcatalog-col_pos = 1.

append fieldcatalog to fieldcatalog.

clear fieldcatalog.

fieldcatalog-fieldname = 'STATU'.

fieldcatalog-seltext_m = 'Status'.

fieldcatalog-col_pos = 2.

append fieldcatalog to fieldcatalog.

clear fieldcatalog.

fieldcatalog-fieldname = 'AEDAT'.

fieldcatalog-seltext_m = 'Item change date'.

fieldcatalog-col_pos = 3.

append fieldcatalog to fieldcatalog.

clear fieldcatalog.

fieldcatalog-fieldname = 'MATNR'.

fieldcatalog-seltext_m = 'Material Number'.

fieldcatalog-col_pos = 4.

append fieldcatalog to fieldcatalog.

clear fieldcatalog.

fieldcatalog-fieldname = 'MENGE'.

fieldcatalog-seltext_m = 'PO quantity'.

fieldcatalog-col_pos = 5.

append fieldcatalog to fieldcatalog.

clear fieldcatalog.

fieldcatalog-fieldname = 'MEINS'.

fieldcatalog-seltext_m = 'Order Unit'.

fieldcatalog-col_pos = 6.

append fieldcatalog to fieldcatalog.

clear fieldcatalog.

fieldcatalog-fieldname = 'NETPR'.

fieldcatalog-seltext_m = 'Net Price'.

fieldcatalog-col_pos = 7.

fieldcatalog-outputlen = 15.

fieldcatalog-do_sum = 'X'. "Display column total

fieldcatalog-datatype = 'CURR'.

append fieldcatalog to fieldcatalog.

clear fieldcatalog.

fieldcatalog-fieldname = 'PEINH'.

fieldcatalog-seltext_m = 'Price Unit'.

fieldcatalog-col_pos = 8.

append fieldcatalog to fieldcatalog.

clear fieldcatalog.

endform. " BUILD_FIELDCATALOG

&----


*& Form BUILD_LAYOUT

&----


  • Build layout for ALV grid report

----


form build_layout.

gd_layout-no_input = 'X'.

gd_layout-colwidth_optimize = 'X'.

gd_layout-totals_text = 'Totals'(201).

  • gd_layout-totals_only = 'X'.

  • gd_layout-f2code = 'DISP'. "Sets fcode for when double

  • "click(press f2)

  • gd_layout-zebra = 'X'.

  • gd_layout-group_change_edit = 'X'.

  • gd_layout-header_text = 'helllllo'.

endform. " BUILD_LAYOUT

&----


*& Form DISPLAY_ALV_REPORT

&----


  • Display report using ALV grid

----


form display_alv_report.

gd_repid = sy-repid.

call function 'REUSE_ALV_GRID_DISPLAY'

exporting

i_callback_program = gd_repid

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

  • i_callback_user_command = 'USER_COMMAND'

  • i_grid_title = outtext

is_layout = gd_layout

it_fieldcat = fieldcatalog[]

  • it_special_groups = gd_tabgroup

  • IT_EVENTS = GT_XEVENTS

i_save = 'X'

  • is_variant = z_template

tables

t_outtab = it_ekko

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.

endform. " DISPLAY_ALV_REPORT

&----


*& Form DATA_RETRIEVAL

&----


  • Retrieve data form EKPO table and populate itab it_ekko

----


form data_retrieval.

select ebeln ebelp statu aedat matnr menge meins netpr peinh

up to 10 rows

from ekpo

into table it_ekko.

endform. " DATA_RETRIEVAL

----


  • Form TOP-OF-PAGE *

----


  • ALV Report Header *

----


Form top-of-page.

*ALV Header declarations

data: t_header type slis_t_listheader,

wa_header type slis_listheader,

t_line like wa_header-info,

ld_lines type i,

ld_linesc(10) type c.

  • Title

wa_header-typ = 'H'.

wa_header-info = 'EKKO Table Report'.

append wa_header to t_header.

clear wa_header.

  • Date

wa_header-typ = 'S'.

wa_header-key = 'Date: '.

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

sy-datum+4(2) '.'

sy-datum(4) INTO wa_header-info. "todays date

append wa_header to t_header.

clear: wa_header.

  • Total No. of Records Selected

describe table it_ekko lines ld_lines.

ld_linesc = ld_lines.

concatenate 'Total No. of Records Selected: ' ld_linesc

into t_line separated by space.

wa_header-typ = 'A'.

wa_header-info = t_line.

append wa_header to t_header.

clear: wa_header, t_line.

call function 'REUSE_ALV_COMMENTARY_WRITE'

exporting

it_list_commentary = t_header.

  • i_logo = 'ideas'.

endform.

Former Member
0 Kudos
187
*&---------------------------------------------------------------------*
*& Report  Y_TOP_PAGE                                                  *
*&                                                                     *
*&---------------------------------------------------------------------*
*&                                                                     *
*&                                                                     *
*&---------------------------------------------------------------------*

REPORT  y_top_page                              .

TABLES : mara.
TYPE-POOLS: slis.

DATA : w_repid LIKE sy-repid.
  w_repid = sy-repid.

DATA : BEGIN OF it_mara OCCURS 0,
       matnr LIKE mara-matnr,
       END OF it_mara.

*layout
DATA: wa_layout           TYPE SLIS_LAYOUT_ALV.
*field catalog
DATA: it_fieldcat_wrt_off TYPE slis_t_fieldcat_alv,
      wa_fieldcat_wrt_off TYPE slis_fieldcat_alv.

START-OF-SELECTION.

  SELECT matnr FROM mara INTO CORRESPONDING FIELDS OF TABLE it_mara.

END-OF-SELECTION.


  CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
   EXPORTING
     i_program_name               = w_repid
   I_INTERNAL_TABNAME           = 'IT_MARA'
*     i_structure_name             = 'IT_MARA'
*   I_CLIENT_NEVER_DISPLAY       = 'X'
   I_INCLNAME                   = w_repid
*   I_BYPASSING_BUFFER           =
*   I_BUFFER_ACTIVE              =
    CHANGING
      ct_fieldcat                  = it_fieldcat_wrt_off[]
   EXCEPTIONS
     inconsistent_interface       = 1
     program_error                = 2
     OTHERS                       = 3
            .
  IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.

  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
      i_callback_program     = w_repid
      i_callback_top_of_page = 'TOP-OF-PAGE'
      is_layout              = wa_layout
      it_fieldcat            = it_fieldcat_wrt_off
    TABLES
      t_outtab               = it_mara
    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.



*-------------------------------------------------------------------*
* Form  TOP-OF-PAGE                                                 *
*-------------------------------------------------------------------*
* ALV Report Header                                                 *
*-------------------------------------------------------------------*
FORM top-of-page.
*ALV Header declarations
  DATA: t_header TYPE slis_t_listheader,
        wa_header TYPE slis_listheader,
        t_line LIKE wa_header-info,
        ld_lines TYPE i,
        ld_linesc(10) TYPE c.

* Title
  wa_header-typ  = 'H'.
  wa_header-info = 'CHANDU REPORT'.
  APPEND wa_header TO t_header.
  CLEAR wa_header.

* Date
  wa_header-typ  = 'S'.
  wa_header-key = 'Date: '.
  CONCATENATE  sy-datum+6(2) '.'
               sy-datum+4(2) '.'
               sy-datum(4) INTO wa_header-info.   "todays date 
 wa_header-info = p_matnr.   " Assign the variable like this 
  APPEND wa_header TO t_header.
  CLEAR: wa_header.

* Total No. of Records Selected
*  describe table it_ekko lines ld_lines.
*  ld_linesc = ld_lines.
*  concatenate 'Total No. of Records Selected: ' ld_linesc
*                    into t_line separated by space.
*  wa_header-typ  = 'A'.
*  wa_header-info = t_line.
*  append wa_header to t_header.
*  clear: wa_header, t_line.

  CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
    EXPORTING
      it_list_commentary = t_header.
*            i_logo             = 'Z_LOGO'.
ENDFORM.                    "top-of-page