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: 

How to color a row using REUSE_ALV_HIERSEQ_LIST_DISPLAY

Former Member
0 Kudos

Hi,

I'm able to color a row using REUSE_ALV_GRID_DISPLAY, I tried the same way to color a row at the item level using 'REUSE_ALV_HIERSEQ_LIST_DISPLAY' but I'm not able to get the row color, please let me know how to acheive this.

Thanks in Advnce

Narayan

9 REPLIES 9

Former Member
0 Kudos

Hi,

Try this,you can be get the colour in ALV Hierarchy report...

Declare value to the fieldcatalog "Emphasize"...

" GW_ALV_FIELDCATALOG-EMPHASIZE = 'C600'. "

Like,you can pass the different value for different colour in every field ..."C600', "C700" ,"C100", "C200".....

Eg.,

TYPE-POOLS : SLIS.

data: GW_ALV_FIELDCATALOG TYPE SLIS_FIELDCAT_ALV,

GT_ALV_FIELDCATALOG TYPE SLIS_T_FIELDCAT_ALV,

GW_ALV_FIELDCATALOG-COL_POS = 1.

GW_ALV_FIELDCATALOG-TABNAME = 'IT_FINAL' .

GW_ALV_FIELDCATALOG-FIELDNAME = 'LIFNR'.

GW_ALV_FIELDCATALOG-SELTEXT_S = 'VENDOR'.

GW_ALV_FIELDCATALOG-EMPHASIZE = 'C600'.

GW_ALV_FIELDCATALOG-OUTPUTLEN = 10.

APPEND GW_ALV_FIELDCATALOG TO GT_ALV_FIELDCATALOG .

CLEAR GW_ALV_FIELDCATALOG.

<=<< Sharing Knowledge is a way to Innovative >=>>

By,

Yoga

0 Kudos

Hi Yoga,

Your code is to make colomns color, but based on a condition I want to change the row color, so your example doesn't work in that case.

Regards,

Narayan

0 Kudos

you need to do 4 things.

1. Add a field in your final internal table which ur going to display.

2.Name the field as----


> color_line(4) TYPE c,

begin of itab,

matnr type mara-matnr,

ernam type mara-ernam,

color_line(4) TYPE c,

end of itab.

3.declare layout ....................> data : it_layout TYPE lvc_s_layo.

4. After filled your fieldcat and before display your ALV

loop at itab assigning to <itab>.

if <itab>-ernam eq 'XYZ'.

<itab>-color_line = 'C600'.

end loop.

it_layout-info_fname = 'COLOR_LINE'.

CALL FUNCTION 'REUSE_ALV_HIERSEQ_LIST_DISPLAY'

exporting

IS_LAYOUT = it_layout

IT_FIELDCAT = your_fieldcat

and pass ur ITAB.

0 Kudos

Hi Sridhar,

I have already done all necessary steps you have mentioned, but still it's not working, I have pasted my code below. please check.

step 1

BEGIN OF ts_item ,

belnr TYPE belnr_d ,

buzei TYPE char03 ,

kunnr TYPE kunnr ,

name1 TYPE name1 ,

stcd1 TYPE stcd1 ,

taxcod TYPE char03 ,

crtnum TYPE char16 ,

amount TYPE char15 ,

color_line TYPE char04,

END OF ts_item ,

step 2

DATA wa_layout TYPE slis_layout_alv.

wa_layout-info_fieldname = 'COLOR_LINE'.

step 3

LOOP AT itab_item ASSIGNING <fs_line>.

IF sy-tabix = 2.

<fs_line>-color_line = 'C600'.

ENDIF.

ENDLOOP.

step 4

Finaly I am passing the internal table to REUSE_ALV_HIERSEQ_LIST_DISPLAY

But the problem is I am not able to see colored lines.

Regards,

Narayan,

0 Kudos

after you assign the value to your layout .........................> wa_layout-info_fieldname = 'COLOR_LINE'

call ur FM " REUSE_ALV_HIERSEQ_LIST_DISPLAY ".

pass the...................> IS_LAYOUT = wa_layout

if its not working send piece of your code.

Regards,

sri

0 Kudos

Hi Sri,

Problem solved I forgot to pass the wa_layout to the FM REUSE_ALV_HIERSEQ_LIST_DISPLAY, Now it's working fine, Thanks a lot.

Narayan

Former Member
0 Kudos

Hi ,

Check this code:

http://www.sap-img.com/abap/line-color-in-alv-example.htm

Regards,

Himanshu

Former Member
0 Kudos

0 Kudos

after you assign the value to your layout .........................> wa_layout-info_fieldname = 'COLOR_LINE'

call ur FM " REUSE_ALV_HIERSEQ_LIST_DISPLAY ".

pass the...................> IS_LAYOUT = wa_layout

if its not working send piece of your code.

Regards,

sri