Application Development and Automation 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: 
Read only

Multicolored rows in ALV Grid Display Sample code!

Former Member
0 Likes
979

Hi Friends,

Would like to know, how to display multicolored rows in ALV Grid Display?

Help we will be rewarded.

Thanks,

CK

6 REPLIES 6
Read only

Former Member
0 Likes
670

Here is a example of the same

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

regards,

Ravi

Read only

0 Likes
670

Thanks for the help Ravi,

Problem resolved. Awarded points.

Read only

Former Member
Read only

Former Member
0 Likes
670

Hi,

Have an additional field ( with 4 characters ) in your internal table which u r displaying.

each character in this field has a specific color attribute.. like...

  • Colour code : *

  • Colour is a 4-char field where : *

  • - 1st char = C (color property) *

  • - 2nd char = color code (from 0 to 7) *

  • 0 = background color *

  • 1 = blue *

  • 2 = gray *

  • 3 = yellow *

  • 4 = blue/gray *

  • 5 = green *

  • 6 = red *

  • 7 = orange *

  • - 3rd char = intensified (0=off, 1=on) *

  • - 4th char = inverse display (0=off, 1=on) *

  • *

fill that field in each row with the color in which u wanna display it.

now initialize i_gs_layout-info_fieldname = 'COLOR_LINE'.

& in your FORM fieldcat_init where you pass the column (field) names & descriptions, use...

ls_fieldcat-emphasize = 'X'.

Thats all u need to do.

Read only

Former Member
0 Likes
670

Run this code & see the output.

TYPE-POOLS : SLIS.

DATA : BEGIN OF WA_SPFLI.

INCLUDE STRUCTURE SPFLI.

DATA : COLOR TYPE SLIS_T_SPECIALCOL_ALV.

DATA : END OF WA_SPFLI.

DATA : IT_COL TYPE SLIS_T_SPECIALCOL_ALV,

WA_COL LIKE LINE OF IT_COL,

IT_SPFLI LIKE TABLE OF WA_SPFLI WITH HEADER LINE.

DATA : MYLAY TYPE SLIS_LAYOUT_ALV.

SELECT * FROM SPFLI INTO CORRESPONDING FIELDS OF TABLE IT_SPFLI .

"WHERE CARRID = 'LH'.

MYLAY-COLTAB_FIELDNAME = 'COLOR'.

LOOP AT IT_SPFLI.

IF IT_SPFLI-COUNTRYFR = 'DE'.

WA_COL-COLOR-COL = '5'.

ELSEIF IT_SPFLI-COUNTRYFR = 'US'.

WA_COL-COLOR-COL = '6'.

ELSEIF IT_SPFLI-COUNTRYFR = 'JP'.

WA_COL-COLOR-COL = '1'.

ELSEIF IT_SPFLI-COUNTRYFR = 'SG'.

WA_COL-COLOR-COL = '4'.

ELSEIF IT_SPFLI-COUNTRYFR = 'ID'.

WA_COL-COLOR-COL = '3'.

ENDIF.

APPEND WA_COL TO IT_COL.

IT_SPFLI-COLOR = IT_COL.

CLEAR WA_COL.

CLEAR IT_COL[].

MODIFY IT_SPFLI.

ENDLOOP.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

I_CALLBACK_PROGRAM = SY-REPID

I_STRUCTURE_NAME = 'SPFLI'

IS_LAYOUT = MYLAY

TABLES

t_outtab = IT_SPFLI

.