cancel
Showing results for 
Search instead for 
Did you mean: 

changing cells of a column in ALV

Former Member
0 Kudos

Hello,

I have an ALV table where the 1st column is an checkbox. Now I want to disable the checkbox in some rows. When there is the string 'GARANTY' in the next field I would like the checkbox to disappear.

thankx and regards

stefan

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Stefan,

In your context node, add an attribute 'checkbox_enabled' of type char01. I presume you know how to make the cell editor of your ALV as a checkbox. Use the following code to bind the 'enabled' property of the checkbox to the context attribute.

data: lr_checkbox type ref to cl_salv_wd_uie_checkbox.

  • initialize checkbox*

lr_checkbox->set_enabled_fieldname( 'checkbox_enabled' ).

*set checkbox as cell editor *

In the method where you populate the internal table, loop through the internal table and set this field. Depending on the value in the field checkbox_enabled, the checkbox will either be greyed out or be enabled. Sample code would be:

loop at itab into wa.

if <fieldname> EQ 'GARANTY'.

wa-checkbox_enabled = abap_false.

else.

wa-checkbox_enabled = abap_true.

endif.

modify itab from wa.

endloop.

Have the checkbox_enabled attribute in the same node that you bind to the ALV table. Hope this helps.

Regards,

Nithya

Former Member
0 Kudos

Hello Nithya,

this was a fast answer and exactly what I needed. Thank you very much.

regards

stefan

Answers (1)

Answers (1)

abhimanyu_lagishetti7
Active Contributor
0 Kudos

Hi

Ooops sorry already posted

data : lr_checkbox type ref to CL_SALV_WD_UIE_CHECKBOX.

data : lr_function_settings TYPE REF TO if_salv_wd_function_settings.

data: lr_function TYPE REF TO cl_salv_wd_function.

data: alv_config_table type ref to CL_SALV_WD_CONFIG_TABLE.

lr_salv_wd_table = wd_this->wd_cpifc_req_process( ).

alv_config_table= lr_salv_wd_table->get_model( ).

lr_function_settings ?= alv_config_table.

lr_function = lr_function_settings->create_function( 'ON_check' ).

CREATE OBJECT lr_checkbox exporting checked_field_name = '<Attribute Name>'.

lr_function->set_editor( lr_checkbox ).

lr_checkbox->GET_READ_ONLY_FIELDNAME( '<attribute Name>' ). " if you want to make the checkbox read only.

Regards

Abhimanyu L

Message was edited by:

Abhimanyu Lagishetti