UPLOADING LOGO
To add a logo to ALV header, we need to have a logo uploaded in to SAP system. The following steps will show you how to upload a customise logo.
First, go to transaction Business Document Navigator (OAOR).
Enter the Class name, Class type, and a name for the logo in Object Key. Then Execute (F8).
On the left-bottom panel, expand Standard Doc. Types and double click on Screen.
On the pop-up window, select the logo file that we want to upload. Then click Open.
Enter description for the logo and press continue. Logo will be saved to system.
ABAP Program
REPORT zaddlogo.
TYPE-POOLS: slis. " SLIS contains all the ALV data types
*&———————————————————————*
*& Data Declaration
*&———————————————————————*
DATA: lt_sflight TYPE TABLE OF sflight.
DATA: g_repid TYPE sy-repid.
*ALV Header declarations
DATA: lt_header TYPE slis_t_listheader,
ls_header TYPE slis_listheader,
lt_line LIKE ls_header-info,
lv_lines TYPE i,
lv_linesc(10) TYPE c.
*&———————————————————————*
*& START-OF-SELECTION
*&———————————————————————*
START-OF-SELECTION.
g_repid = sy-repid.
*&—– Fetch data from the database —–*
SELECT *
FROM sflight
INTO TABLE lt_sflight.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = g_repid
i_callback_top_of_page = 'TOP-OF-PAGE'
i_structure_name = 'SFLIGHT'
TABLES
t_outtab = lt_sflight.
*———————————————————–*
* Form TOP-OF-PAGE
* Generating Report Header
*———————————————————–*
FORM top-of-page.
*&—– Alv report header —–*
* Title
ls_header-typ = 'H'.
ls_header-info = 'SFLIGHT Table Report'.
APPEND ls_header TO lt_header.
CLEAR ls_header.
* Date
ls_header-typ = 'S'.
ls_header-key = 'Date: '.
CONCATENATE sy-datum+6(2) '.'
sy-datum+4(2) '.'
sy-datum(4)
INTO ls_header-info. "todays date
APPEND ls_header TO lt_header.
CLEAR: ls_header.
* Total No. of Records Selected
DESCRIBE TABLE lt_sflight LINES lv_lines.
lv_linesc = lv_lines.
CONCATENATE 'Total No. of Records Selected: ' lv_linesc
INTO lt_line SEPARATED BY space.
ls_header-typ = 'A'.
ls_header-info = lt_line.
APPEND ls_header TO lt_header.
CLEAR: ls_header, lt_line.
*&—– Pass data and field catalog to ALV function module —–*
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
it_list_commentary = lt_header
i_logo = 'TESTLOGO'.
ENDFORM. "top-of-page
TYPE-POOLS: slis. " SLIS contains all the ALV data types
*&———————————————————————*
*& Data Declaration
*&———————————————————————*
DATA: lt_sflight TYPE TABLE OF sflight.
DATA: g_repid TYPE sy-repid.
*ALV Header declarations
DATA: lt_header TYPE slis_t_listheader,
ls_header TYPE slis_listheader,
lt_line LIKE ls_header-info,
lv_lines TYPE i,
lv_linesc(10) TYPE c.
*&———————————————————————*
*& START-OF-SELECTION
*&———————————————————————*
START-OF-SELECTION.
g_repid = sy-repid.
*&—– Fetch data from the database —–*
SELECT *
FROM sflight
INTO TABLE lt_sflight.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = g_repid
i_callback_top_of_page = 'TOP-OF-PAGE'
i_structure_name = 'SFLIGHT'
TABLES
t_outtab = lt_sflight.
*———————————————————–*
* Form TOP-OF-PAGE
* Generating Report Header
*———————————————————–*
FORM top-of-page.
*&—– Alv report header —–*
* Title
ls_header-typ = 'H'.
ls_header-info = 'SFLIGHT Table Report'.
APPEND ls_header TO lt_header.
CLEAR ls_header.
* Date
ls_header-typ = 'S'.
ls_header-key = 'Date: '.
CONCATENATE sy-datum+6(2) '.'
sy-datum+4(2) '.'
sy-datum(4)
INTO ls_header-info. "todays date
APPEND ls_header TO lt_header.
CLEAR: ls_header.
* Total No. of Records Selected
DESCRIBE TABLE lt_sflight LINES lv_lines.
lv_linesc = lv_lines.
CONCATENATE 'Total No. of Records Selected: ' lv_linesc
INTO lt_line SEPARATED BY space.
ls_header-typ = 'A'.
ls_header-info = lt_line.
APPEND ls_header TO lt_header.
CLEAR: ls_header, lt_line.
*&—– Pass data and field catalog to ALV function module —–*
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
it_list_commentary = lt_header
i_logo = 'TESTLOGO'.
ENDFORM. "top-of-page
Output: