Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Colors in ALV

Former Member
0 Kudos

Hi friends,

I want to display the cells in different colors in ALV grid format.

How to do that.

Points would be rewarded for helpful answers.

Tina

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi Tina

IF you are talking about the colouring of the <b>columns</b> in ALV grid you can use <b>emphasise</b> option in fieldcatalog.

emphasize (highlights column in colour)

Value range: SPACE, 'X' or 'Cxyz' (x:'1'-'9'; y,z: '0'=off '1'=on)

'X' = The column is highlighted in the default color for colour highlighting.

'Cxyz' = The column is highlighted in the coded colour:

- C: Color (coding must start with C)

- x: Color number

- y: Intensified

- z: Inverse

Check this if it helps.

Regards

Suruchi

9 REPLIES 9

Former Member
0 Kudos

Tina,

Are you talking about OO Control or REUSE function?

Check out this program that uses a REUSE function.

http://www.geocities.com/mpioud/Z_ALV_DYNAMIC_DATA_V3.html

Regards,

Ravi

0 Kudos

Hi,

Ravi I am doing it with simple ALV, I dont even know about OO control or REUSE function.

Suruchi I will try doing it with emphasise. Thanx anyway.

Tina

0 Kudos

Tina,

There is nothing called as SIMPLE ALV, either you use a function module REUSE_ALV_GRID_DISPLAY or use OO Controls. Take a lok at the program and I am sure you will understand.

Regards,

Ravi

Note : Please mark all the helpful answers

0 Kudos

Oh sorry Ravi.

Now I understood.I am using REUSE_ALV_GRID_DISPLAY.

I could not understand before.I hope you understand.

I tried solution that suruchi gave me,it worked.

Thanx both of you.

Tina

0 Kudos

Tina,

Using emphasize, you can assign only one color to all the coimns you want. However, if you use STYLE column of the field catalog, you can assign different colours to different columns.

regards,

Ravi

0 Kudos

Hi TIna,

EMPHASIZE will give only one color to column, but check my code, it will give change the color of cell of one column diferently.

1, 10 rows vbeln show different color, and 5,20 show different color. just copy paste and see the output.

conditionally you can change the colors of each cell in a column.

Regards

vijay

0 Kudos

Hi Vijay,

I tried your code.It really worked like magic.

I would study that properly.

But in my case I just wanted same color in a column.

So my problem was solved with emphasize only.

Thanks a lot for additional information.

I really appreciate.

Tina

Former Member
0 Kudos

Hi Tina

IF you are talking about the colouring of the <b>columns</b> in ALV grid you can use <b>emphasise</b> option in fieldcatalog.

emphasize (highlights column in colour)

Value range: SPACE, 'X' or 'Cxyz' (x:'1'-'9'; y,z: '0'=off '1'=on)

'X' = The column is highlighted in the default color for colour highlighting.

'Cxyz' = The column is highlighted in the coded colour:

- C: Color (coding must start with C)

- x: Color number

- y: Intensified

- z: Inverse

Check this if it helps.

Regards

Suruchi

former_member188685
Active Contributor
0 Kudos

Hi,

one column cells different colours check this report...

REPORT ZTESTALV.

TYPE-POOLS: SLIS.
INCLUDE <ICON>.
*- Fieldcatalog
DATA: IT_FIELDCAT  TYPE LVC_T_FCAT,
      IT_FIELDCAT1  TYPE SLIS_T_FIELDCAT_ALV..
*- For Events
DATA:IT_EVENTS TYPE SLIS_T_EVENT.

DATA:  X_FIELDCAT  TYPE LVC_S_FCAT,
        X_FIELDCAT1  TYPE SLIS_FIELDCAT_ALV.
DATA:X_LAYOUT TYPE LVC_S_LAYO.
TABLES: LIPS.
DATA: BEGIN OF IT_VBAP OCCURS 0,
      VBELN LIKE VBAP-VBELN,
      POSNR LIKE VBAP-POSNR,
      CELLCOLOR TYPE LVC_T_SCOL,
     END OF IT_VBAP.

SELECT VBELN
       POSNR
       UP TO 20 ROWS
      INTO CORRESPONDING FIELDS OF TABLE IT_VBAP
      FROM VBAP.


DATA:L_POS TYPE I VALUE 1.
CLEAR: L_POS.
L_POS = L_POS + 1.
X_FIELDCAT-SELTEXT = 'VBELN'.
X_FIELDCAT-FIELDNAME = 'VBELN'.
X_FIELDCAT-TABNAME = 'ITAB'.
X_FIELDCAT-COL_POS    = L_POS.
X_FIELDCAT-OUTPUTLEN = '10'.
APPEND X_FIELDCAT TO IT_FIELDCAT.
CLEAR X_FIELDCAT.
L_POS = L_POS + 1.

X_FIELDCAT-SELTEXT = 'POSNR'.
X_FIELDCAT-FIELDNAME = 'POSNR'.
X_FIELDCAT-TABNAME = 'ITAB'.
X_FIELDCAT-COL_POS    = L_POS.
X_FIELDCAT-OUTPUTLEN = '5'.
APPEND X_FIELDCAT TO IT_FIELDCAT.
CLEAR X_FIELDCAT.
L_POS = L_POS + 1.
X_LAYOUT-CTAB_FNAME = 'CELLCOLOR'.
DATA: LS_CELLCOLOR TYPE LVC_S_SCOL.
DATA: L_INDEX TYPE SY-TABIX.
LOOP AT IT_VBAP.
  L_INDEX = SY-TABIX.
  if l_index = 1 or l_index = 10.
  LS_CELLCOLOR-FNAME = 'VBELN'.
  LS_CELLCOLOR-COLOR-COL = '6'.
  LS_CELLCOLOR-COLOR-INT = '1'.
  APPEND LS_CELLCOLOR TO IT_VBAP-CELLCOLOR.
  MODIFY IT_VBAP INDEX L_INDEX TRANSPORTING CELLCOLOR.
  endif.
  if l_index = 5 or l_index = 20.
  LS_CELLCOLOR-FNAME = 'VBELN'.
  LS_CELLCOLOR-COLOR-COL = '4'.
  LS_CELLCOLOR-COLOR-INT = '1'.
  APPEND LS_CELLCOLOR TO IT_VBAP-CELLCOLOR.
  MODIFY IT_VBAP INDEX L_INDEX TRANSPORTING CELLCOLOR.
  endif.
ENDLOOP.


CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'
  EXPORTING
    I_CALLBACK_PROGRAM       = SY-REPID
    IS_LAYOUT_LVC            = X_LAYOUT
    IT_FIELDCAT_LVC          = IT_FIELDCAT
  TABLES
    T_OUTTAB                 = IT_VBAP[]
  EXCEPTIONS
    PROGRAM_ERROR            = 1
    OTHERS                   = 2.
IF SY-SUBRC <> 0.
  MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
          WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.

if you want to change the color of rows..

http://www.sapdevelopment.co.uk/reporting/alv/alvgrid_color.htm

Regards

vijay