Skip to Content
0
Former Member
Jun 30, 2011 at 06:58 AM

CELL COLOR IN ALV GETS REPEATED

19 Views

Hello Experts,

I need to COLOR each and every CELL in an ALV GRID DISPLAY. I have used the below code lines :

TYPES : BEGIN OF T_EKPO,

-


(OTHER FIELDS)

CELL_COLOR TYPE LVC_T_SCOL,

END OF T_EKPO.

Ater that I have written CODE -LINES FOR FIELDCATALOG.

For the LAYOUT I have written,

form build_layout.

gd_layout-no_input = 'X'.

gd_layout-colwidth_optimize = 'X'.

gd_layout-coltab_fieldname = 'CELL_COLOR'.

endform. " BUILD_LAYOUT

FOR DATA FETCHING :

form data_retrieval.

select ebeln ebelp statu aedat matnr menge meins netpr peinh

up to 10 rows

from ekpo

into CORRESPONDING FIELDS OF TABLE it_ekpo.

endform.

FOR FILLING COLOR IN CELLS :

form set_color.

DATA: WA_CELLCOLOR TYPE LVC_S_SCOL.

DATA: ld_color TYPE sy-tabix.

LOOP AT IT_EKPO into wa_ekpo.

LD_color = SY-TABIX.

  • IF ld_color = 8.

  • ld_color = 1.

  • ENDIF.

WA_CELLCOLOR-FNAME = 'EBELN'.

WA_CELLCOLOR-COLOR-COL = LD_color.

WA_CELLCOLOR-COLOR-INT = '1'.

WA_CELLCOLOR-COLOR-INV = '0'.

APPEND WA_CELLCOLOR TO wa_ekpo-CELL_COLOR.

MODIFY it_ekpo from wa_ekpo INDEX ld_color TRANSPORTING CELL_COLOR.

  • if wa_ekpo-netpr gt 0.

WA_CELLCOLOR-FNAME = 'NETPR'.

WA_CELLCOLOR-COLOR-COL = LD_color.

WA_CELLCOLOR-COLOR-INT = '1'.

WA_CELLCOLOR-COLOR-INV = '0'.

APPEND WA_CELLCOLOR TO wa_ekpo-CELL_COLOR.

MODIFY it_ekpo from wa_ekpo INDEX ld_color TRANSPORTING CELL_COLOR.

  • endif.

WA_CELLCOLOR-FNAME = 'AEDAT'.

WA_CELLCOLOR-COLOR-COL = LD_color.

WA_CELLCOLOR-COLOR-INT = '1'.

WA_CELLCOLOR-COLOR-INV = '0'.

APPEND WA_CELLCOLOR TO wa_ekpo-CELL_COLOR.

MODIFY it_ekpo from wa_ekpo INDEX ld_color TRANSPORTING CELL_COLOR.

ENDLOOP.

IF ld_color = 8.

ld_color = 1.

ENDIF.

ENDFORM. " SET_CELL_COLOURS

FINALLY I HAVE PASSED ALL THE GD_LAYOT , FIELDCATALOG ETC. IN FM 'REUSE_ALV_GRID_DISPLAY.

MY PROBLEM IS : after the 7th line of each column I'm getting the SAME COLOR for the remaining 3 lines (bluish-gray), but I want the colors to be displayed alternatively for THE LAST 3 CELLS of each columns .

PLEASE HELP.