04-26-2006 2:35 PM
I would like to dynamically set a color for a single in a list.
Ie rather than code:
If var = 'x'. write l_field color col_negative.
elseif var = 'y' write l_field color col_total.
elseif var = 'z' write l_field color col_group.
endif.
I would like to code it as follows:
data: l_color(10) type c.
if l_var = 'x'.
move 'col_negative' to l_color.
elseif l_var = 'y' move 'col_total to l_color.
elseif l_var = 'z' move 'col_group' to l_color.
endif.
write: l_field color l_color.
The color command does not seem to like being passed a variable, rather it has to be told explicitly what the color should be set at.
Is there a way around this?
04-26-2006 2:40 PM
No, like you say: the color command does not support passed variables.
04-26-2006 2:40 PM
No, like you say: the color command does not support passed variables.
04-26-2006 2:44 PM
Thanks for your replies. I suspected that I could not pass a variable to the color command - you have confirmed that for me.
04-26-2006 2:57 PM
Check this report...You might find it helpfull:
REPORT Z_ATG_DUMMY.
DATA I TYPE I VALUE 0.
DATA COL(15) TYPE C.
WRITE:/9 'INTENSIFIED ON',27 'INTENSIFIED OFF',48 'INVERSE'.
SKIP 2.
WHILE I < 8.
CASE I.
WHEN 0. COL = 'COL_BACKGROUND '.
WHEN 1. COL = 'COL_HEADING '.
WHEN 2. COL = 'COL_NORMAL '.
WHEN 3. COL = 'COL_TOTAL '.
WHEN 4. COL = 'COL_KEY '.
WHEN 5. COL = 'COL_POSITIVE '.
WHEN 6. COL = 'COL_NEGATIVE '.
WHEN 7. COL = 'COL_GROUP '.
ENDCASE.
FORMAT INTENSIFIED COLOR = I.
WRITE: /(4) I, AT 7 SY-VLINE,
COL, SY-VLINE,
COL INTENSIFIED OFF, SY-VLINE,
COL INVERSE.
I = I + 1.
ENDWHILE.
Greetings,
Blag.
04-26-2006 3:16 PM
Alvaro,
Thanks for that, but what I am trying to do is a little complicated. When a user clicks on a field in a list I want to change the color of that field depending on the field value. To achieve this I am using the command
MODIFY CURRENT LINE FIELD FORMAT itab-field
COLOR COL_KEY INTENSIFIED ON.
It would be much neater if I could achieve this by passing a variable to the "color" command but it seems this is not possible.
To make things even more complicated I have to get the fieldname which has been clicked on using "get_cursor". The "format" part of the above command will also not accept a variable so it seems this too will have to be hard coded.
04-26-2006 2:41 PM
To color a report, you must use...
FORMAT COLOR X.
FORMAT COLOR OFF.
Where 'X' is a number going from 0 to 7...If I'm not wrong -:P
Greetings,
Blag.