Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

ALV Using OOPs(Row color & Cell color)

Hi,

Can any one give the code for ALV grid display using OO Programming to color a row and to color a cell.

Any helpful answers can be appreciated.

Tags:
Former Member
Former Member replied

hi sandhya,

tables:

sbook.

data:

w_table type ref to cl_gui_custom_container,

w_grid type ref to cl_gui_alv_grid.

data:

t_catalog type lvc_t_fcat,

fs_catalog like line of t_catalog,

fs_layout type lvc_s_layo.

data begin of fs_sflight.

data check type c.

include structure sflight.

data t_color type lvc_t_scol.

data end of fs_sflight.

data fs_color type lvc_s_scol.

data :

t_sflight like

standard table

of fs_sflight.

select *

from sflight

into corresponding fields of table t_sflight.

call screen 1985.

----


  • MODULE STATUS_1985 OUTPUT

----


*

----


module status_1985 output.

set pf-status 'STATUS_1985'.

create object w_table

exporting container_name = 'CONTAINER'.

create object w_grid

exporting i_parent = w_table.

call function 'LVC_FIELDCATALOG_MERGE'

exporting

  • I_BUFFER_ACTIVE =

i_structure_name = 'SFLIGHT'

  • I_CLIENT_NEVER_DISPLAY = 'X'

  • I_BYPASSING_BUFFER =

  • I_INTERNAL_TABNAME =

changing

ct_fieldcat = t_catalog

EXCEPTIONS

INCONSISTENT_INTERFACE = 1

PROGRAM_ERROR = 2

OTHERS = 3.

if sy-subrc <> 0.

MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

endif.

fs_layout-grid_title = 'YASH TECHNOLOGIES'.

fs_layout-smalltitle = 'X'.

*fs_layout-NO_HEADERS = 'X'.

fs_layout-no_hgridln = 'X'.

fs_layout-no_vgridln = 'X'.

*FS_LAYOUT-NO_TOOLBAR = 'X'.

*FS_LAYOUT-NO_ROWMARK = 'X'.

fs_layout-zebra = 'X'.

  • fs_layout-info_fname = 'CHECK'.

FS_LAYOUT-CTAB_FNAME = 'T_COLOR'.

fs_layout-NO_TOTLINE = 'X'.

loop at t_catalog into fs_catalog.

case fs_catalog-fieldname.

  • WHEN 'CHECK'.

  • FS_CATALOG-CHECKBOX = 'X'.

    • FS_CATALOG-DO_SUM = 'X'.

    • FS_CATALOG-EMPHASIZE = 'C610'.

  • MODIFY T_CATALOG FROM FS_CATALOG.

when 'CARRID'.

fs_catalog-hotspot = 'X'.

modify t_catalog from fs_catalog.

when 'CONNID'.

fs_catalog-no_out = 'X'.

modify t_catalog from fs_catalog.

when 'PRICE'.

  • fs_catalog-no_sum = 'X'.

fs_catalog-emphasize = 'C310'.

modify t_catalog from fs_catalog.

when 'PLANETYPE'.

fs_catalog-icon = 'X'.

modify t_catalog from fs_catalog.

endcase.

endloop.

clear fs_catalog.

FS_CATALOG-FIELDNAME = 'CHECK'.

FS_CATALOG-CHECKBOX = 'X'.

FS_CATALOG-EMPHASIZE = 'C610'.

FS_CATALOG-OUTPUTLEN = '3'.

FS_CATALOG-COLTEXT = 'BOX'.

APPEND FS_CATALOG TO T_CATALOG.

read table t_sflight index 5 into fs_sflight.

fs_color-fname = 'SEATSMAX'.

fs_color-color-col = '7'.

fs_color-color-int = '1'.

append fs_color to fs_sflight-t_color.

modify t_sflight index 5 from fs_sflight.

read table t_sflight index 7 into fs_sflight.

fs_color-fname = ' '.

fs_color-color-col = '5'.

fs_color-color-int = '1'.

append fs_color to fs_sflight-t_color.

modify t_sflight index 7 from fs_sflight.

call method w_grid->set_table_for_first_display

exporting

is_layout = fs_layout

  • i_structure_name = 'SBOOK'

changing

it_outtab = t_sflight

it_fieldcatalog = t_catalog.

endmodule. "STATUS_1985 OUTPUT

----


  • MODULE USER_COMMAND_1985 INPUT

----


*

----


module user_command_1985 input.

leave program.

regards,

veeresh

Message was edited by:

veereshbabu ponnada

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question