Skip to Content
avatar image
Former Member

How to disable a field(Cell) in Webdynpro ALV based on an action

Hi Experts,

I have a requirement in which we need to disable a field(cell) based on a action in the ALV.

ALV is already populated with data, and I have created event handler ON_CELL_ACTION, which has been triggered through WDDOMODIFYVIEW method of View.

Below is the ALV

When we select the check box - Update Frequency HMS (Which is highlighted in red box in below fig) then the check box Update Frequency-Date & Time (Which is highlighted in Blue box) should be disabled. Only that particular cell need to be disabled neither the entire row nor the entire column.

Below is the code which I have written in ON_CELL_ACTION event handler

DATA: lv_column TYPE string.

DATA lv_value TYPE char1.

DATA lo_cmp_usage TYPE REF TO if_wd_component_usage.

DATA lo_interfacecontroller TYPE REF TO iwci_salv_wd_table.

DATA lo_value TYPE REF TO cl_salv_wd_config_table.

DATA lo_field TYPE REF TO cl_salv_wd_field.

DATA lo_check TYPE REF TO cl_salv_wd_uie_checkbox.

DATA lo_field_settings TYPE REF TO if_salv_wd_field_settings.

DATA lo_column TYPE REF TO cl_salv_wd_column.

DATA: lo_column_settings TYPE REF TO if_salv_wd_column_settings.

DATA: lo_table_settings TYPE REF TO if_salv_wd_table_settings.

FIELD-SYMBOLS <fs> TYPE data.

" Get the value from the Parameter

lv_column = r_param->column.

ASSIGN r_param->value->* TO <fs>.

lo_value = <fs>.

" Initialize the Used componenent

lo_cmp_usage = wd_this->wd_cpuse_alv_mat_display( ).

IF lo_cmp_usage->has_active_component( ) IS INITIAL.

lo_cmp_usage->create_component( ).

ENDIF.

lo_interfacecontroller = wd_this->wd_cpifc_alv_mat_display( ).

lo_value = lo_interfacecontroller->get_model( ).

" Check if the selected check box is ZZHMS_CHK_BOX

IF lv_column EQ 'ZZHMS_CHK_BOX'.

" If the selected check box is not initial

IF lv_value IS NOT INITIAL.

lo_column_settings ?= lo_value.

" Get the column reference.

lo_column = lo_column_settings->get_column( 'ZZDATETIME_CHK_BOX' ).

lo_field = lo_value->if_salv_wd_field_settings~get_field( 'ZZDATETIME_CHK_BOX' ).

lo_field->set_reference_field('ZZDATETIME_CHK_BOX' ).

" Create new object for the checkbox

CREATE OBJECT lo_check

EXPORTING

checked_fieldname = 'ZZDATETIME_CHK_BOX'.

" Set the readonly fieldname and the read only parameter

lo_check->set_read_only_fieldname( 'ZZDATETIME_CHK_BOX' ).

lo_check->set_read_only( abap_true ).

lo_column->set_cell_editor( lo_check ).

lo_table_settings ?= lo_value.

lo_table_settings->set_read_only( abap_false ).

ENDIF.

ENDIF.

And I am triggering this event in WDDOMODIFYVIEW method.

DATA lo_cmp_usage TYPE REF TO if_wd_component_usage.

DATA lo_interfacecontroller TYPE REF TO iwci_salv_wd_table.

DATA lo_value TYPE REF TO cl_salv_wd_config_table.

lo_cmp_usage = wd_this->wd_cpuse_alv_mat_display( ).

IF lo_cmp_usage->has_active_component( ) IS INITIAL.

lo_cmp_usage->create_component( ).

ENDIF.

lo_interfacecontroller = wd_this->wd_cpifc_alv_mat_display( ).

lo_value = lo_interfacecontroller->get_model( ).

CALL METHOD lo_value->if_salv_wd_table_settings~set_cell_action_event_enabled( value = abap_true ).

Currently the entire table is getting disabled. Kindly help me to resolve the issue.

Your valuable comments are appreciable.

Regards,

Pradeep.

ALV1.jpg (49.5 kB)
ALV2.jpg (49.5 kB)
Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

2 Answers

  • Best Answer
    avatar image
    Former Member
    Apr 05, 2016 at 07:26 AM

    Hi Pradeep,

    Please use the method set_read_only_fieldname method in the class interface CL_SALV_WD_UIE_CHECKBOX .


    1. Add two more attribute of type WDY_BOOLEAN to you ALV node (may be directly to your dictionary structure or to your node ).

    2. as per ur requirement when attribute_hms is abap_true same time attribute_date_time should be abap_false , so pass abap_true or false to these attributes as required

    3. based on your column match condition (If..else...endif) call this method set_read_only_fieldname


    IF lv_column EQ 'ZZHMS_CHK_BOX'.

    lo_check->set_read_only_fieldname( ' attribute_hms ' ).

    else.

    lo_check->set_read_only_fieldname( 'attribute_date_time ' ).

    endif.


    may be this logic help you...

    Thanks

    Nidhi

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Apr 05, 2016 at 09:31 AM

    Hi Nidhi,

    Thanks for your valuable comments...

    Regards,

    Pradeep

    Add comment
    10|10000 characters needed characters exceeded