2009 Aug 07 7:36 AM
Hi Experts!
I am trying to implement CL_SALV_TREE for creating a tree report which will be capable of performing AVERAGE and TOTAL on numeric (INT / DEC) columns. Secondly, I am trying to change the color (style) of the cell (item) based on its value.
To add aggregations I am doing something like this:
DATA: lr_aggregations TYPE REF TO cl_salv_aggregations.
lr_aggregations = gr_tree->get_aggregations( ).
lr_aggregations->clear( ).
TRY.
lr_aggregations->add_aggregation( columnname = 'BKJOB'
aggregation = if_salv_c_aggregation=>total ).
lr_aggregations->add_aggregation( columnname = 'CNJOB'
aggregation = if_salv_c_aggregation=>total ).
lr_aggregations->add_aggregation( columnname = 'AVCAP'
aggregation = if_salv_c_aggregation=>total ).
CATCH cx_salv_not_found cx_salv_data_error cx_salv_existing.
ENDTRY.And for changing the STYLE (background color) of a cell (item) I am using following code:
TRY .
LOOP AT it_nodes INTO wa_nodes.
l_node_key = wa_nodes-key.
nodes = gr_tree->GET_NODES( ).
node = nodes->get_node( l_node_key ).
item = node->get_item( 'BKCAP' ).
lv_val = item->get_value( ).
ASSIGN lv_val->* TO <lv_value>.
IF <lv_value> GT '100.00'.
item->set_style( lv_high ). "5 (Red)
ELSEIF <lv_value> BETWEEN '80.00' AND '100.00'.
item->set_style( lv_med ). "7 (Yellow)
ELSEIF <lv_value> LT '80.00'.
item->set_style( lv_low ). "6 (Green)
ENDIF.
ENDLOOP.
CATCH cx_salv_msg.
ENDTRY.The color changes work fine for leaf nodes but it doesn't if it is parent node. If I comment the aggregation code, it displays the color.
I believe ADD_AGGREGATION method overrides the STYLE of the NODE ITEM.
Is it a bug? Any fixes?
Thanks & Regards,
Aabhas K Vishnoi
Hi Experts!
I am trying to implement CL_SALV_TREE for creating a tree report which will be capable of performing AVERAGE and TOTAL on numeric (INT / DEC) columns. Secondly, I am trying to change the color (style) of the cell (item) based on its value.
To add aggregations I am doing something like this:
DATA: lr_aggregations TYPE REF TO cl_salv_aggregations.
lr_aggregations = gr_tree->get_aggregations( ).
lr_aggregations->clear( ).
TRY.
lr_aggregations->add_aggregation( columnname = 'BKJOB'
aggregation = if_salv_c_aggregation=>total ).
lr_aggregations->add_aggregation( columnname = 'CNJOB'
aggregation = if_salv_c_aggregation=>total ).
lr_aggregations->add_aggregation( columnname = 'AVCAP'
aggregation = if_salv_c_aggregation=>total ).
CATCH cx_salv_not_found cx_salv_data_error cx_salv_existing.
ENDTRY.And for changing the STYLE (background color) of a cell (item) I am using following code:
TRY .
LOOP AT it_nodes INTO wa_nodes.
l_node_key = wa_nodes-key.
nodes = gr_tree->GET_NODES( ).
node = nodes->get_node( l_node_key ).
item = node->get_item( 'BKCAP' ).
lv_val = item->get_value( ).
ASSIGN lv_val->* TO <lv_value>.
IF <lv_value> GT '100.00'.
item->set_style( lv_high ). "5 (Red)
ELSEIF <lv_value> BETWEEN '80.00' AND '100.00'.
item->set_style( lv_med ). "7 (Yellow)
ELSEIF <lv_value> LT '80.00'.
item->set_style( lv_low ). "6 (Green)
ENDIF.
ENDLOOP.
CATCH cx_salv_msg.
ENDTRY.The color changes work fine for leaf nodes but it doesn't if it is parent node. If I comment the aggregation code, it displays the color.
I believe ADD_AGGREGATION method overrides the STYLE of the NODE ITEM.
Is it a bug? Any fixes?
Thanks & Regards,
Aabhas K Vishnoi
2009 Aug 07 3:13 PM
Actually, when you don't add the aggregations in your TREE, the Node record is exactly same as your very first Leaf so, it takes the same property as the Leaf's property. That's why we can see the color on the first node when we don't apply the Aggregations.
Now, when we apply the aggregations, system applies its own Style on the NODE (Dark Blue color) and this style overrides the style of the Leaf.
Regards,
Naimesh Patel
2009 Aug 07 3:52 PM
Hi Naimesh,
Thanks for replying.
I understand your point but ideally aggregation must not override the style.
Anyway, is there a way that I can set my own style to a parent node after aggregation is done?
regards,
Aabhas
2009 Aug 07 4:29 PM
is there a way that I can set my own style to a parent node after aggregation is done?
I guess, Aggregation Style would always have higher priority than the Custom Priority.
Regards,
Naimesh Patel