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

Former Member
0 Kudos

hw to insert header and footer in alv.(grid display).

urgent..

thanks..

waiting....

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Have a look at below link.

<a href="http://www.sap-img.com/abap/example-of-a-simple-alv-grid-report.htm">Report: ALV Header</a>

Also look into BCALV* in se38 for sample codes.

I hope it helps.

Best Regards,

Vibha

*Please mark all the helpful answers

6 REPLIES 6

Former Member
0 Kudos

Have a look at below link.

<a href="http://www.sap-img.com/abap/example-of-a-simple-alv-grid-report.htm">Report: ALV Header</a>

Also look into BCALV* in se38 for sample codes.

I hope it helps.

Best Regards,

Vibha

*Please mark all the helpful answers

0 Kudos

COULD U GIV ME CODING FOR THAT

0 Kudos

COULD U GIV ME CODING FOR HEADER AND FOOTER

Former Member
0 Kudos

Use FM REUSE_ALV_COMMENTARY_WRITE to display header.

&----


*& Form sub_event_call

&----


  • text

----


  • -->P_V_EVENTS_REPL text

----


FORM sub_event_call USING p_v_events.

CALL FUNCTION 'REUSE_ALV_EVENTS_GET'

EXPORTING

i_list_type = 0

IMPORTING

et_events = p_v_events

  • 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.

ENDFORM. " sub_event_call

*&----


*& Form POPULATE_EVENT

*&----


  • text

*----


  • --> p1 text

  • <-- p2 text

*----


FORM populate_event.

CLEAR wa_event.

READ TABLE v_events INTO wa_event WITH KEY name = 'TOP_OF_PAGE'.

IF sy-subrc EQ 0.

wa_event-form = 'TOP_OF_PAGE'.

MODIFY v_events FROM wa_event TRANSPORTING form

WHERE name = wa_event-form.

ENDIF.

endform.

&----


*& Form TOP_OF_PAGE

&----


  • text

----


----


FORM top_of_page.

DATA: t_header TYPE slis_t_listheader,

wa_header TYPE slis_listheader,

l_date LIKE sy-datum.

l_date = sy-datum - 1.

    • Title

wa_header-typ = 'S'.

wa_header-key = 'Yesterday Report : '.

IF rb_crt = 'X'.

wa_header-info = 'Job Creation Summary'. "todays date

ELSEIF rb_rpl = 'X'.

wa_header-info = 'Job Re-plan Summary'. "todays date

ELSE.

wa_header-info = 'Planned for Completion Summary'. "todays date

ENDIF.

APPEND wa_header TO t_header.

CLEAR: wa_header.

wa_header-typ = 'S'.

wa_header-key = 'Date : '.

CONCATENATE l_date+6(2) '.'

l_date+4(2) '.'

l_date(4) INTO wa_header-info. "todays date

APPEND wa_header TO t_header.

CLEAR: wa_header.

CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

EXPORTING

it_list_commentary = t_header.

  • i_logo = 'Z_LOGO'.

ENDFORM. "TOP_OF_PAGE

Former Member
0 Kudos

Hi chang,

Here are the steps for that:

  • 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