REUSE_ALV_GRID_DISPLAY- 04

light111Grid ALV title and top of page with picture

 

 

The previous post shows REUSE_ALV_GRID_DISPLAY- 03 how to edit, save and refresh the alv. This post describes how to set the grid alv title and also the top of page in alv and displaying header info and image.


Code Snippet:


DATA: lt_spfli TYPE TABLE OF spfli.
DATA: ls_layout TYPE slis_layout_alv.
DATA: lt_fieldcat TYPE slis_t_fieldcat_alv.

START-OF-SELECTION.
PERFORM data_selection.
PERFORM build_layout.
PERFORM build_fieldcatalog.
PERFORM display_alv.
&———————————————————————
& Form DATA_SELECTION
&———————————————————————*
FORM data_selection .
SELECT * FROM spfli INTO TABLE lt_spfli.
ENDFORM. ” DATA_SELECTION

&———————————————————————
& Form BUILD_LAYOUT
&———————————————————————*
FORM build_layout.
ls_layout-zebra = abap_true.
ls_layout-colwidth_optimize = abap_true.
ENDFORM. ” BUILD_LAYOUT

&———————————————————————
& Form BUILD_FIELDCATALOG
&———————————————————————*
FORM build_fieldcatalog .
CALL FUNCTION ‘REUSE_ALV_FIELDCATALOG_MERGE’
EXPORTING
i_program_name = sy-repid
“I_INTERNAL_TABNAME =
i_structure_name = ‘SPFLI’
CHANGING
ct_fieldcat = lt_fieldcat
EXCEPTIONS
inconsistent_interface = 1
program_error = 2
OTHERS = 3.

ENDFORM. ” BUILD_FIELDCATALOG
&———————————————————————
& Form DISPLAY_ALV
&———————————————————————*
FORM display_alv .

CALL FUNCTION ‘REUSE_ALV_GRID_DISPLAY’
EXPORTING
i_callback_program = sy-repid
i_grid_title = ‘Flight Info’
is_layout = ls_layout
it_fieldcat = lt_fieldcat
TABLES
t_outtab = lt_spfli
EXCEPTIONS
program_error = 1
OTHERS = 2.

ENDFORM. ” DISPLAY_ALV


Program Output:

10.jpg


Code Snippet: TOP OF PAGE with header info


DATA: lt_spfli TYPE TABLE OF spfli.
DATA: ls_layout TYPE slis_layout_alv.
DATA: lt_fieldcat TYPE slis_t_fieldcat_alv.

START-OF-SELECTION.
PERFORM data_selection.
PERFORM build_layout.
PERFORM build_fieldcatalog.
PERFORM display_alv.
&———————————————————————
& Form DATA_SELECTION
&———————————————————————*
FORM data_selection .
SELECT * FROM spfli INTO TABLE lt_spfli.
ENDFORM. ” DATA_SELECTION

&———————————————————————
& Form BUILD_LAYOUT
&———————————————————————*
FORM build_layout.
ls_layout-zebra = abap_true.
ls_layout-colwidth_optimize = abap_true.
ENDFORM. ” BUILD_LAYOUT

&———————————————————————
& Form BUILD_FIELDCATALOG
&———————————————————————*
FORM build_fieldcatalog .
CALL FUNCTION ‘REUSE_ALV_FIELDCATALOG_MERGE’
EXPORTING
i_program_name = sy-repid
“I_INTERNAL_TABNAME =
i_structure_name = ‘SPFLI’
CHANGING
ct_fieldcat = lt_fieldcat
EXCEPTIONS
inconsistent_interface = 1
program_error = 2
OTHERS = 3.

ENDFORM. ” BUILD_FIELDCATALOG
&———————————————————————
& Form DISPLAY_ALV
&———————————————————————*
FORM display_alv .

CALL FUNCTION ‘REUSE_ALV_GRID_DISPLAY’
EXPORTING
i_callback_program = sy-repid
i_callback_top_of_page = ‘ALV_HEADER’  ” this is a subroutine name
is_layout = ls_layout
it_fieldcat = lt_fieldcat
TABLES
t_outtab = lt_spfli
EXCEPTIONS
program_error = 1
OTHERS = 2.

ENDFORM. ” DISPLAY_ALV

FORM alv_header.
DATA: lt_comment TYPE slis_t_listheader.
DATA: ls_comment TYPE LINE OF slis_t_listheader.
ls_comment-typ = ‘H’.
ls_comment-info = ‘Flight Information’.
APPEND ls_comment TO lt_comment.
CALL FUNCTION ‘REUSE_ALV_COMMENTARY_WRITE’
EXPORTING
it_list_commentary = lt_comment.
ENDFORM.


Program Output: The header info displayed in the top of page area.

1.jpg


Next we have to display the image in the grid lav top of page area. Before that we have to upload our image to the sap server.  Do the below steps to upload the image.


here an image file in my computer desktop.

2

Execute transaction- OAER

3

Provide below details- here we provide the object key name as- FLIGHT_ALV this will be used in the ALV program and execute.

4

The below screen appears . here select Create tab and expand the tree and double click on SCREEN.

5

It open the pop up to select the image from the workstation to upload. Choose the image and select open.

6

Click on Continue.

7

The image uploaded.

8


Code Snippet: Make use of logo in alv header


DATA: lt_spfli TYPE TABLE OF spfli.
DATA: ls_layout TYPE slis_layout_alv.
DATA: lt_fieldcat TYPE slis_t_fieldcat_alv.

START-OF-SELECTION.
PERFORM data_selection.
PERFORM build_layout.
PERFORM build_fieldcatalog.
PERFORM display_alv.
&———————————————————————
& Form DATA_SELECTION
&———————————————————————*
FORM data_selection .
SELECT * FROM spfli INTO TABLE lt_spfli.
ENDFORM. ” DATA_SELECTION

&———————————————————————
& Form BUILD_LAYOUT
&———————————————————————*
FORM build_layout.
ls_layout-zebra = abap_true.
ls_layout-colwidth_optimize = abap_true.
ENDFORM. ” BUILD_LAYOUT

&———————————————————————
& Form BUILD_FIELDCATALOG
&———————————————————————*
FORM build_fieldcatalog .
CALL FUNCTION ‘REUSE_ALV_FIELDCATALOG_MERGE’
EXPORTING
i_program_name = sy-repid
“I_INTERNAL_TABNAME =
i_structure_name = ‘SPFLI’
CHANGING
ct_fieldcat = lt_fieldcat
EXCEPTIONS
inconsistent_interface = 1
program_error = 2
OTHERS = 3.

ENDFORM. ” BUILD_FIELDCATALOG
&———————————————————————
& Form DISPLAY_ALV
&———————————————————————*
FORM display_alv .

CALL FUNCTION ‘REUSE_ALV_GRID_DISPLAY’
EXPORTING
i_callback_program = sy-repid
i_callback_top_of_page = ‘ALV_HEADER’
is_layout = ls_layout
it_fieldcat = lt_fieldcat
TABLES
t_outtab = lt_spfli
EXCEPTIONS
program_error = 1
OTHERS = 2.

ENDFORM. ” DISPLAY_ALV

FORM alv_header.
DATA: lt_comment TYPE slis_t_listheader.
DATA: ls_comment TYPE LINE OF slis_t_listheader.
ls_comment-typ = ‘H’.
ls_comment-info = ‘Flight Information’.
APPEND ls_comment TO lt_comment.
CALL FUNCTION ‘REUSE_ALV_COMMENTARY_WRITE’
EXPORTING
it_list_commentary = lt_comment
i_logo = ‘FLIGHT_ALV’.  ” this is the object key in Tx- OAER
ENDFORM.


Program Output:

9.jpg


 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s