Wednesday, November 17, 2010

Top-of-page and End-of-page in ALV GRID using METHODS

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = sy-repid
i_background_id = 'ALV_BACKGROUND'
i_callback_html_top_of_page = 'TOP_OF_PAGE'
i_callback_html_end_of_list = 'END_OF_LIST_HTML'

is_layout = wa_layout
it_fieldcat = it_fieldcat
i_default = 'X'
i_save = 'A'
is_print = wa_print
TABLES
t_outtab = it_result
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
*-------------------------------------------------------------------------------------*
FORM top_of_page USING cl_dd TYPE REF TO cl_dd_document.

DATA: lv_per(255).

* for space
CALL METHOD cl_dd->add_gap
EXPORTING
width = 7.

* to add text in heading
CALL METHOD cl_dd->add_text
EXPORTING
text = text-001
sap_style = cl_dd_document=>heading           "Sap styles are heading,Key, success, etc
sap_fontsize = cl_dd_document=>medium       "Sap font sizes are small,medium, large
sap_emphasis = cl_dd_document=>strong.      "Sap emphases are strong , emphasis

* for gap between two text
CALL METHOD cl_dd->add_gap
EXPORTING
width = 23.

* for new text
CALL METHOD cl_dd->add_text
EXPORTING
text = text-001
sap_style = cl_dd_document=>key
sap_color = cl_dd_document=>list_background
sap_fontsize = cl_dd_document=>large
sap_emphasis = cl_dd_document=>emphasis.


* for new line
CALL METHOD cl_dd->new_line
EXPORTING
repeat = 0.

CALL METHOD cl_dd->add_gap
EXPORTING
width = 7.

CALL METHOD cl_dd->add_text
EXPORTING
text = text-001
sap_emphasis = cl_dd_document=>strong
style_class = space.

CALL METHOD cl_dd->add_gap
EXPORTING
width = 25.


CALL METHOD cl_dd->add_text
EXPORTING
text = text-001
sap_emphasis = cl_dd_document=>strong
style_class = space.

ENDFORM. "top_of_page


*-----------------------------------------------------------------------------------------*
*& Form END-OF-PAGE
*-----------------------------------------------------------------------------------------*

FORM end_of_list_html USING end TYPE REF TO cl_dd_document.
DATA: ls_text TYPE sdydo_text_element,
l_grid TYPE REF TO cl_gui_alv_grid,
f(14) TYPE c VALUE 'SET_ROW_HEIGHT'.

ls_text = 'Footer title'.

* add icon (red triangle)
CALL METHOD end->add_icon
EXPORTING
sap_icon = 'ICON_MESSAGE_ERROR_SMALL'.

* add text (via variable)
CALL METHOD end->add_text
EXPORTING
text = ls_text
sap_emphasis = 'strong'.

* add new line (start new line)
CALL METHOD end->new_line.

* display text(bold)
CALL METHOD end->add_text
EXPORTING
text = 'Bold text'
sap_emphasis = 'strong'.

*set height of this section
CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
IMPORTING
e_grid = l_grid.

CALL METHOD l_grid->parent->parent->(f)
EXPORTING
id = 3
height = 10.

ENDFORM. "end_of_list_html.