cancel
Showing results for 
Search instead for 
Did you mean: 

how to assign colour to particular field

Former Member
0 Kudos

*how to assign colour to particular field.*

My code for editing paricular fields is as below. i want to assign color to the field lifnr

*****GET ALV CONFIGURATION SETTINGSUSING I/F CONTROLLERGET_MODEL

DATA: l_ref_INTERFACECONTROLLER TYPE REF TO IWCI_SALV_WD_TABLE .

l_ref_INTERFACECONTROLLER = wd_This->wd_CpIfc_Alv_Fr_Edit( ).

data:

l_VALUE type ref to Cl_Salv_Wd_Config_Table.

l_VALUE = l_ref_INTERFACECONTROLLER->Get_Model(

).

**************set entire alv as read only = false*****************

CALL METHOD L_VALUE->IF_SALV_WD_TABLE_SETTINGS~SET_READ_ONLY

EXPORTING

VALUE = ABAP_false.

***************GET ALL COLUMNS OF ALV into an internaltable ****usethe method get_columns**of class *cl_salv_wd_config_table***

DATA : LT_COLUMNS TYPE SALV_WD_T_COLUMN_REF,"INTAB

LS_COLUMNS LIKE LINE OF LT_COLUMNS."WORKAREA

DATA : LT_COLUMNS TYPE SALV_WD_T_COLUMN_REF,"INTAB

LS_COLUMNS LIKE LINE OF LT_COLUMNS."WORKAREA

CALL METHOD L_VALUE->IF_SALV_WD_COLUMN_SETTINGS~GET_COLUMNS

RECEIVING

VALUE = LT_COLUMNS

LOOP AT LT_COLUMNS INTO LS_COLUMNS ."FOR ALL FIELDS

if LS_COLUMNS-ID = 'LIFNR' OR LS_COLUMNS-ID = 'LAND1' . "FOR PARTICULAR FIELDS

CREATE OBJECT LR_INPUT

EXPORTING

VALUE_FIELDNAME = LS_COLUMNS-ID.

CALL METHOD LS_COLUMNS-R_COLUMN->SET_CELL_EDITOR

EXPORTING

VALUE = LR_INPUT

.

ENDIF.

ENDLOOP.

Moderator message: moved from ABAP General.

Edited by: Thomas Zloch on Oct 13, 2011 2:00 PM

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi Dear,

1. To color a column:-

use the method set_cell_design in class CL_SALV_ WD_COLUMN and there u provide the details of the alv column.

Check:-

Column coloring in ALV

To color a particular cell:-

Add one attirbute cell_color in your context node . And based on some condition you set set the value of the color in it.

like :-

IF

(CONTEXT_NODE-ATTRIBUTE1) > 30.

CONTEXT_NODE-CELL_COLOUR = CL_WD_TABLE_COLUMN=>E_CELL_DESIGN-GOODVALUE_LIGHT.

ELSEIF (CONTEXT_NODE-ATTRIBUTE1)< 10.

CONTEXT_NODE-CELL_COLOUR = CL_WD_TABLE_COLUMN=>E_CELL_DESIGN-BADVALUE_LIGHT.

Now afetr instantiating your alv and using get_model method of it set this attribute for the particular column. As you need to get row identity and column identity to adentify a particular cell. So get the column reference and give the value 'CELL_COLOUR' in the SET_CELL_DESIGN_FIELDNAME.

like:-

LOOP AT LT_COLUMNS INTO LS_COLUMN .

CASE LS_COLUMN-ID .

WHEN 'column_name'.

CREATE OBJECT LR_INPUT_FIELD

EXPORTING

VALUE_FIELDNAME = LS_COLUMN-ID.

LR_COLUMN = LV_VALUE->IF_SALV_WD_COLUMN_SETTINGS~GET_COLUMN( ID = LS_COLUMN-ID ).

LR_COLUMN->SET_CELL_EDITOR( LR_INPUT_FIELD ).

LR_COLUMN->SET_CELL_DESIGN_FIELDNAME( VALUE = 'CELL_COLOUR' ).

ENDCASE.

ENDLOOP.

Check:-

Conditionally Assigning Colors and Input Enable to ALV Columns in Web Dynpro ABAP

3. To color a row:-

Proceed as above and set cell color for all the column.

Hope this will be helpful.

Former Member
0 Kudos

Dear PRABHU1985 ,

Just to let you know that there is a specific forum on SDN for Webdynpro ABAP questions.

Please check this post:

[;

Take a look at WD: WDR_TEST_TABLE

Kind Regards

/Ricardo Quintas