cancel
Showing results for 
Search instead for 
Did you mean: 

Enable/disable check box based on Condition.

Former Member
0 Kudos

Hi,

I want enable/disable checkbox in same column based on a condition in internal table

I have created checkbox by defining char1 under context node

I am using following code for checkbox creation.

lr_column = l_value->if_salv_wd_column_settings~get_column( 'PCRTD' ).

  CREATE OBJECT lr_checkbox
    EXPORTING
      checked_fieldname = 'PCRTD'.
  lr_checkbox->set_enabled( 'X' ).
  lr_column->set_cell_editor( lr_checkbox ).

how do we achive this?

Rgds

Vara

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

If i understand your query correctly, you want to create a checkbox in an ALV column and based on some condition you wnat to enable/disable it.

Please follow these steps:

1. Create an attribute 'EDITABLE' type boolean under the same node that is bound to your ALV.

2. Create the checkbox and bind the readonly property using the following code.

DATA: lt_columns TYPE salv_wd_t_column_ref ,
        ls_columns TYPE salv_wd_s_column_ref .

  DATA: l_column_header  TYPE REF TO cl_salv_wd_column_header .

  lt_columns = l_column_settings->get_columns( ) .

  LOOP AT lt_columns INTO ls_columns .
    CASE ls_columns-id  .
      WHEN 'PCRTD' .
" create checkbox
        DATA: lr_chkbox TYPE REF TO cl_salv_wd_uie_checkbox.
        CREATE OBJECT lr_chkbox
          EXPORTING
            checked_fieldname = ls_columns-id
        ls_columns-r_column->set_cell_editor( lr_chkbox ) .
"binding the read only property
        lr_chkbox->set_read_only_fieldname( 'EDITABLE' ).

ENDLOOP.

3. No just pass abap_false/abap_true to the field EDITABLE to make the checkbox editable/disabled .

and bind the table to the node.

Regards,

Radhika.

Former Member
0 Kudos

Thank you.It worked!

Awarded points.

Answers (0)