Sie sind auf Seite 1von 3

using styles in alv

Added by Venkat Appikonda, last edited by Venkat Appikonda on Jan 27, 2009
(view change)

*----------------------------------------------------------------------------------
-----*

* report name

*----------------------------------------------------------------------------------
-----*

REPORT ZALV_DEMO .

*----------------------------------------------------------------------------------
-----*

* includes for alv , this is the include fir

*----------------------------------------------------------------------------------
-----*

* Include for all style values

INCLUDE <CL_ALV_CONTROL>.

* please do not look for the include class in se24, it shows it doesnt exist

*----------------------------------------------------------------------------------
-----*

* internal table declarations

*----------------------------------------------------------------------------------
-----*

* Internal table for final output data

DATA: I_FLIGHT TYPE STANDARD TABLE OF SFLIGHT.

* Internal table for field catalog info

DATA: I_FIELDS TYPE LVC_T_FCAT.

* Field symbol for field catalog

FIELD-SYMBOLS: <WA_FIELDS> TYPE LVC_S_FCAT.

*----------------------------------------------------------------------------------
-----*

* start of selection

*----------------------------------------------------------------------------------
-----*

START-OF-SELECTION.
PERFORM GET_DATA.

PERFORM BUILD_FIELDCAT.

PERFORM DISPLAY_ALV.

*&---------------------------------------------------------------------*

*& Form get_data

*----------------------------------------------------------------------*

FORM GET_DATA .

* Select data

SELECT * FROM SFLIGHT

INTO TABLE I_FLIGHT

UP TO 10 ROWS.

ENDFORM. " get_data

*&---------------------------------------------------------------------*

*& Form build_fieldcat

*----------------------------------------------------------------------*

FORM BUILD_FIELDCAT .

CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'

EXPORTING

I_STRUCTURE_NAME = 'SFLIGHT'

CHANGING

CT_FIELDCAT = I_FIELDS.

* Changing the style of field catalog

LOOP AT I_FIELDS ASSIGNING <WA_FIELDS>.

IF SY-TABIX > 4.

<WA_FIELDS>-style=ALV_STYLE_FONT_ITALIC.

ELSE.

<WA_FIELDS>-style=ALV_STYLE_FONT_BOLD.

ENDIF.

ENDLOOP.

ENDFORM. " build_fieldcat


*&---------------------------------------------------------------------*

*& Form display_alv

*----------------------------------------------------------------------*

FORM DISPLAY_ALV .

* Calling the FM to display ALV report

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'

EXPORTING

I_STRUCTURE_NAME = 'SFLIGHT'

I_GRID_TITLE = 'Style demo'(001)

IT_FIELDCAT_LVC = I_FIELDS

TABLES

T_OUTTAB = I_FLIGHT.

ENDFORM. " display_alv

Das könnte Ihnen auch gefallen