REUSE_ALV_GRID_DISPLAY- 01

light111Grid ALV and few layout property 

 

 

This post shows how to crate a very basic grid alv and uses of few layout property.


Code Snippet: 


DATA: lt_spfli TYPE TABLE OF spfli.

START-OF-SELECTION.
PERFORM data_selection.
PERFORM display_alv.
&———————————————————————
& Form DATA_SELECTION
&———————————————————————
FORM data_selection .
SELECT * FROM spfli INTO TABLE lt_spfli.
ENDFORM. ” DATA_SELECTION
&———————————————————————
& Form DISPLAY_ALV
&———————————————————————
FORM display_alv .
CALL FUNCTION ‘REUSE_ALV_GRID_DISPLAY’
EXPORTING
i_callback_program = sy-repid
i_structure_name = ‘SPFLI’
TABLES
t_outtab = lt_spfli
EXCEPTIONS
program_error = 1
OTHERS = 2.

ENDFORM. ” DISPLAY_ALV


Program Output:

1.jpg


Code Snippet: Layout property – ZEBRA used for the stripped pattern


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

START-OF-SELECTION.
PERFORM data_selection.
PERFORM build_layout.
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.

ENDFORM. ” BUILD_LAYOUT

&———————————————————————
& Form DISPLAY_ALV
&———————————————————————*
FORM display_alv .
CALL FUNCTION ‘REUSE_ALV_GRID_DISPLAY’
EXPORTING
i_callback_program = sy-repid
i_structure_name = ‘SPFLI’
is_layout = ls_layout
TABLES
t_outtab = lt_spfli
EXCEPTIONS
program_error = 1
OTHERS = 2.

ENDFORM. ” DISPLAY_ALV


Program Output:

2.jpg


Code Snippet: Layout property EDIT makes all the fields in the grid alv as editable.


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

START-OF-SELECTION.
PERFORM data_selection.
PERFORM build_layout.
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-edit = abap_true.
ENDFORM. ” BUILD_LAYOUT

&———————————————————————
& Form DISPLAY_ALV
&———————————————————————*
FORM display_alv .
CALL FUNCTION ‘REUSE_ALV_GRID_DISPLAY’
EXPORTING
i_callback_program = sy-repid
i_structure_name = ‘SPFLI’
is_layout = ls_layout
TABLES
t_outtab = lt_spfli
EXCEPTIONS
program_error = 1
OTHERS = 2.

ENDFORM. ” DISPLAY_ALV


Program Output:

3.jpg


 

One comment

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 )

Twitter picture

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

Facebook photo

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

Connecting to %s