on 07-24-2008 4:47 PM
Hi Experts,
I have written following piece of code to change the color of a cell based on condition, but some how its not working. I have define m_alv_model in attribute of the view type ref to CL_SALV_WD_CONFIG_TABLE. My ALV is working fine, but cell colors are not getting changed. Pls suggest.
* Data declarations for ALV
DATA: lt_columns TYPE salv_wd_t_column_ref,
ls_column TYPE salv_wd_s_column_ref,
lo_column TYPE REF TO cl_salv_wd_column ,
lo_col_head TYPE REF TO cl_salv_wd_column_header ,
lo_ref_cmp_usage TYPE REF TO if_wd_component_usage,
lo_ref_interfacecontroller TYPE REF TO iwci_salv_wd_table ,
lo_value TYPE REF TO cl_salv_wd_config_table.
* Get reference to the Component usage of the ALV.
lo_ref_cmp_usage = wd_this->wd_cpuse_alv( ).
IF lo_ref_cmp_usage->has_active_component( ) IS INITIAL.
lo_ref_cmp_usage->create_component( ).
ENDIF.
* Get reference to the Interface controller of the ALV.
lo_ref_interfacecontroller = wd_this->wd_cpifc_alv( ).
lo_value = lo_ref_interfacecontroller->get_model( ).
wd_this->m_alv_model = lo_value.
* Get the Columns of the ALV
CALL METHOD lo_value->if_salv_wd_column_settings~get_columns
RECEIVING
value = lt_columns.
* Get reference to each column and set the column heading.
LOOP AT lt_columns INTO ls_column.
lo_column = ls_column-r_column.
CASE ls_column-id.
WHEN 'VARIANCE'.
lo_col_head = lo_column->get_header( ) .
lo_col_head->set_ddic_binding_field( ).
DATA: lr_input_field TYPE REF TO cl_salv_wd_uie_input_field.
CREATE OBJECT lr_input_field EXPORTING value_fieldname = 'VARIANCE'.
lo_column->set_cell_editor( lr_input_field ).
lo_column->set_cell_design_fieldname( value = 'CELL_COLOR' ).
WHEN 'CELL_COLOR'.
CALL METHOD lo_column->set_visible(
EXPORTING
value = '00'
).
ENDCASE.
ENDLOOP.
Step-3: While populating the data into the Context which is bound to the ALV - Do the following based on the content of "VARIANCE" Field to set its colour accordingly -
* VARIANCE
ls_final-variance = ls_final-current_amount - ls_final-ses_forecast.
IF ls_final-variance < 0.
ls_final-cell_color = CL_WD_TABLE_COLUMN=>E_CELL_DESIGN-BADVALUE_DARK.
ELSE.
ls_final-cell_color = CL_WD_TABLE_COLUMN=>E_CELL_DESIGN-STANDARD.
ENDIF.
Hi ,
Please check this code i have used this to show a icons accoring to the values tat iam getting from the bapi.
create object lr_image.
lr_image->set_source_fieldname( 'RISK_CRITICALITY' ).
lr_column->set_cell_editor( lr_image ).
loop at lt_projhealth assigning <fs_risk>.
if <fs_risk>-criticality_desc eq 'VERY HIGH'.
<fs_risk>-risk_criticality = 'ICON_STATUS_CRITICAL'.
elseif <fs_risk>-criticality_desc eq 'HIGH'.
<fs_risk>-risk_criticality = 'ICON_STATUS_ALERT'.
elseif <fs_risk>-criticality_desc eq 'MODERATE'.
<fs_risk>-risk_criticality = 'ICON_LED_YELLOW'.
elseif <fs_risk>-criticality_desc eq 'LOW'.
<fs_risk>-risk_criticality = 'ICON_STATUS_BEST'.
elseif <fs_risk>-criticality_desc eq 'VERY LOW'.
<fs_risk>-risk_criticality = 'ICON_LED_GREEN'.
endif.
Regards,
Muneesh Gitta.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi
For adding the icon to the custom button use this piece of code
data : lr_buttonui type ref to cl_salv_wd_fe_button.
data : button type ref to cl_salv_wd_function.
create object lr_buttonui.
lr_buttonui->set_text( 'SAVE' ).
lr_buttonui->set_image_source( 'ICON_SYSTEM_SAVE' ).
BUTTON = L_VALUE->IF_SALV_WD_FUNCTION_SETTINGS~CREATE_FUNCTION( ID = 'SAVE' ).
BUTTON->SET_EDITOR( LR_BUTTONUI ).
Regards
Tamil
Edited by: Tamilselvan K on Jul 25, 2008 6:30 AM
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
for me a similar coding works, as long as I'm using not using the alternating table design.
Did you already check it using the standard table design?
Regards,
Udo
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
87 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.