You are on page 1of 3

TYPE-POOLS: slis.

" SLIS contains all the ALV data types

*&---------------------------------------------------------------------*
*& Data Declaration
*&---------------------------------------------------------------------*

DATA: BEGIN OF wa_sbook,


status(4).
INCLUDE STRUCTURE sbook.
DATA: END OF wa_sbook.
DATA: it_sbook

TYPE TABLE OF sbook.

DATA: it_fieldcat

TYPE slis_t_fieldcat_alv,

wa_fieldcat

TYPE slis_fieldcat_alv.

*&---------------------------------------------------------------------*
*& START-OF-SELECTION
*&---------------------------------------------------------------------*
START-OF-SELECTION.

*Fetch data from the database


SELECT * UP TO 10 ROWS FROM sbook INTO TABLE it_sbook.

*Build field catalog


wa_fieldcat-fieldname

= 'STATUS'.

" Fieldname in the data table

wa_fieldcat-seltext_m

= 'Status'.

" Column description in the output

APPEND wa_fieldcat TO it_fieldcat.

*Merge Field Catalog

CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'


EXPORTING
i_structure_name

= 'SBOOK'

CHANGING
ct_fieldcat

= it_fieldcat

EXCEPTIONS
inconsistent_interface

= 1

program_error

= 2

OTHERS

= 3.

*Pass data and field catalog to ALV function module to display ALV list
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
it_fieldcat

= it_fieldcat

TABLES
t_outtab

= it_sbook

EXCEPTIONS
program_error = 1
OTHERS

Output

= 2.

Status column is added to the field catalog along all the fields of structure SBOOK.

You might also like