0% found this document useful (0 votes)
272 views3 pages

Add Column ALV

The document declares data types and structures needed to display an ALV list of book data from the SBOOK structure. It fetches up to 10 rows from the database into a table, builds a field catalog with a 'STATUS' column, merges the field catalog, and calls an ALV function to display the list with the added status field.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
272 views3 pages

Add Column ALV

The document declares data types and structures needed to display an ALV list of book data from the SBOOK structure. It fetches up to 10 rows from the database into a table, builds a field catalog with a 'STATUS' column, merges the field catalog, and calls an ALV function to display the list with the added status field.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 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