cancel
Showing results for 
Search instead for 
Did you mean: 

ALV: Color cells in subtotals. Is it possible?

Former Member
0 Kudos

Hi,

I have an ALV-report which initially shows subtotals only. The users want to see specific colors in specific cells of the subtotals if possible.

Is it?

Regards

Thomas

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Thomas,

1 You are right.

It seems it is not possible

to

colour the line of SUBTOTAL

(Not the normal data lines)

thru the conventional facility

provided by ALV Functions.

2. Using raw home logic,

one can color it as mentioned in the last answer.

but not thru the functionality provided by SAP for

alv purpose.

This answer may not help your answer,

but probably it will clarify our doubts

and probably the DIFFERENT answers

which many have replied.

Regards,

Amit Mittal.

Former Member
0 Kudos

I'm sorry!

I thought the right answer was in this last messages. But I don't seem to make it work. I can't catch the event.

Do any of you have an example that works?

I'm using the class CL_GUI_ALV_GRID (not list or tree and not FM REUSE_ALV....) with method set_table_for first_display. I have implemented the event-handler which works fine with the DOUBLE_CLICK event, but not with END_OF_LIST. I have also tried event SUBTOTAL_TEXT - just to see if it could reveal anything usefull.

I have tried the BCALV-examples but they seems not to work either.

Regards

Thomas

Former Member
0 Kudos

Hi Thomas,

It's not possible to color sub total cells.We can give colors to cell level, column level and row level.

But we cant do coloring for totals. If you want to put your own button and handling may be you can do it. To do that you need to do lot more things.

To my knowledge we cant do it. If I am wrong some body can correct me.

Thanks & Regards,

Siir.

Former Member
0 Kudos

Thanks all. It didn't solve my problem, but I can't spend any more time on this. The users have to accept the facts.

You all get 2 pts for quick respons.

If newcomers by any way have a solution, please feel free to post it anytime!

/Thomas

Answers (7)

Answers (7)

former_member188685
Active Contributor
0 Kudos

hi If it is normal alv u can do it in different ways.

in end-of-list event

read the report and modify the line where ever subtotals

appear.

i will give a simple code have a look

*-End of list

X_EVENTS_DATA-NAME = 'END_OF_LIST'.

X_EVENTS_DATA-FORM = 'LIST_MODIFY_OUPUT'.

APPEND X_EVENTS_DATA TO IT_EVENTS_DATA.

in the form

READ LINE SY-INDEX INDEX SY-LSIND.

IF SY-SUBRC = 0.

MODIFY LINE SY-INDEX INDEX SY-LSIND

FIELD FORMAT IT_DISPLAY-TOTAL COLOR 4 INVERSE.

ENDIF.

jayanthi_jayaraman
Active Contributor
0 Kudos

Hi,

Check this link.

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

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

It is about colouring a cell and colouring a line.If so,kindly reward points by clicking the star on the left of reply.

Former Member
0 Kudos

Hi,

Follow this link...

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

I hope it will work you.

Thanks.

Former Member
0 Kudos
Former Member
0 Kudos

Thomas,

While building the Field Catalog, For the Subtotal field, have a stmt

waFieldcatalog-fieldname = 'SUBTOTAL'

<b>waFieldCatalog-emphasize = 'X'.</b>

append waFieldCatalog to ifieldCatalog

Thanks

Kam

venkata_ramisetti
Active Contributor
0 Kudos

Hi Thomas,

Please check the Demo program ERGP2120.

It has this feature.

Step1: define you internal table like below

DATA: BEGIN OF mylist OCCURS 20, " Internal table for preparing

zuordnung(8) TYPE c,

belegnr(10) TYPE c,

ba(2) TYPE c,

bldatum TYPE d,

bs(2) TYPE c,

s(4) TYPE c VALUE ' ',

wrg(4) TYPE c,

betrag TYPE p DECIMALS 2,

colinfo TYPE slis_t_specialcol_alv,

END OF mylist.

Step2:

LOOP AT lt_mylist.

REFRESH gt_color.

CLEAR gt_color.

IF lt_mylist-betrag > 500000.

CLEAR gt_color.

gt_color-fieldname = 'BETRAG'.

gt_color-color-col = cl_gui_resources=>list_col_positive.

gt_color-color-int = 0.

APPEND gt_color.

ELSEIF lt_mylist-betrag < 100000.

CLEAR gt_color.

gt_color-fieldname = 'BETRAG'.

gt_color-color-col = cl_gui_resources=>list_col_negative.

gt_color-color-int = 0.

APPEND gt_color.

ENDIF.

lt_mylist-colinfo[] = gt_color[].

MODIFY lt_mylist.

ENDLOOP.

Thanks,

Ramakrishna

Message was edited by: Ramakrishna Prasad

former_member188685
Active Contributor
0 Kudos

Hi coloring the cells..

delcare a field in ur internal table.

cellcolor type lvc_t_scol.

data: ls_cellcolor type lvc_s_scol.

and then for that

while populating the totals

ls_cellcolor-fname = 'TOTAL' .

ls_cellcolor-color-col = '7' .

ls_cellcolor-color-int = '1'

APPEND ls_cellcolor TO IT_FINAL-cellcolor

u can get different color for that cell.

regards

vijay

Former Member
0 Kudos

hi Vijay,

Do you mean it is possible to do it with the ALV-calculated subtotals in the same way as with the detail-lines?

I'm asking about coloring af subtotal-<u>line</u> - <b>not</b> a subtotal-<u>column</u>!

-> Ramakrishna - the program ERGP2120 is not found in the SAP-system I'm working with. (46c)

Regards

Thomas

former_member188685
Active Contributor
0 Kudos

ok

I got it.

in that case i think modify the output in end-of-list will solve ur problem.

check it.

regards

vijay