REUSE_ALV_GRID_DISPLAY- 02

light111Fieldcatalog use in grid alv

 

 

The previous post REUSE_ALV_GRID_DISPLAY- 01 shows how to create a basic grid alv and working on few layout property. This post shows how to create field catalog and display grid alv.


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.
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_structure_name = ‘SPFLI’  ” no need to pass the structure name as we have fieldcatalog table
is_layout = ls_layout
it_fieldcat = lt_fieldcat
TABLES
t_outtab = lt_spfli
EXCEPTIONS
program_error = 1
OTHERS = 2.

ENDFORM. ” DISPLAY_ALV


Program Output:

1.jpg


 

Advertisements

One thought on “REUSE_ALV_GRID_DISPLAY- 02

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 )

Google+ photo

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

Connecting to %s