cancel
Showing results for 
Search instead for 
Did you mean: 

Read only ALV help

Former Member
0 Kudos

I'm trying to get a drop down with key in an ALV to toggle a field's readonly attribute on the current selection only. I have the drop down with key working and it sets the readonly attribute but it does it for every record. When I try to add an index it just hangs.

Here's my code:

METHOD onactionchange_attendee_info.

   DATA: lv_attendee_type TYPE wd_this->element_hcp1_data-z_attendee_type,

             lr_elem TYPE REF TO if_wd_context_element,

             lv_index TYPE sy-index.

   lv_index = context_element->get_index( ).

   lr_elem = wd_context->get_element( ).

   context_element->get_attribute( EXPORTING name = 'Z_ATTENDEE_TYPE' IMPORTING value = lv_attendee_type ).

   CASE lv_attendee_type.

     WHEN 'B'.

       lr_elem->set_attribute( name `SHOWEMPLOYEE` value = abap_true ).

     WHEN 'E'.

       lr_elem->set_attribute( name `SHOWEMPLOYEE` value = abap_false ).

     WHEN 'H'.

       lr_elem->set_attribute( name `SHOWEMPLOYEE` value = abap_true ).

   ENDCASE.

ENDMETHOD.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi David,

    Are you using ALV or Table.

In case of ALV you have to use ALV events.

In table you can add your method in action handler.

How ever your read only atttribute does not seems to be inside your your context node structure, it sees you have kept it as a context attribute for which the changes are getting effected to all records. Keep your attribute inside your context node ( displayed in ALV / Table ) .

Set the read only propety & then use action handler.

Revert me in case of any issue.

Regards,

Monishankar Chatterjee

Answers (3)

Answers (3)

Former Member
0 Kudos

I just figured it out. Thanks for all the help.

METHOD onactionchange_attendee_info.

   DATA: lv_attendee_type TYPE wd_this->element_hcp1_data-z_attendee_type.

   context_element->get_attribute( EXPORTING name = 'Z_ATTENDEE_TYPE' IMPORTING value = lv_attendee_type ).

   CASE lv_attendee_type.

     WHEN 'B'.

       CALL METHOD context_element->set_attribute_property

         EXPORTING

           attribute_name = 'EMPLOYEE'

           property       = context_element->e_property-read_only

           value          = abap_true.

       CALL METHOD context_element->set_attribute_property

         EXPORTING

           attribute_name = 'NPI'

           property       = context_element->e_property-read_only

           value          = abap_true.

     WHEN 'E'.

       CALL METHOD context_element->set_attribute_property

         EXPORTING

           attribute_name = 'EMPLOYEE'

           property       = context_element->e_property-read_only

           value          = abap_false.

       CALL METHOD context_element->set_attribute_property

         EXPORTING

           attribute_name = 'NPI'

           property       = context_element->e_property-read_only

           value          = abap_true.

     WHEN 'H'.

       CALL METHOD context_element->set_attribute_property

         EXPORTING

           attribute_name = 'EMPLOYEE'

           property       = context_element->e_property-read_only

           value          = abap_true.

       CALL METHOD context_element->set_attribute_property

         EXPORTING

           attribute_name = 'NPI'

           property       = context_element->e_property-read_only

           value          = abap_false.

   ENDCASE.

ENDMETHOD.

Former Member
0 Kudos

Monishankar,

You're right it's a table. My code is in the 'OnSelect' in the drop down by key field. I tried to use the "context_element" parameter that is being imported for the read only attribute but it just hangs eventually timing out with an error.

Something like this doesn't seem to work for me.

context_element->set_attribute( name `SHOWEMPLOYEE` value = abap_true ).

If I do it with this it works but changes the whole column.

lr_elem->set_attribute( name `SHOWEMPLOYEE` value = abap_true ).

That's what I can't seem to figure out.



former_member210266
Active Participant
0 Kudos

Hi David

Try doing it in the ALV event ON_CELL_ACTION.

It has importing parameter R_PARAM which will give you the current column and index.

Regards

Swati