cancel
Showing results for 
Search instead for 
Did you mean: 

Select Options Read Only Fields

Former Member
0 Kudos

Hi, currently I am using the SAP provided select options component and while I am able to set a particular field to read only easily enough at creation, it seems that I am unable to do during run time. I have the code below which is envoked by the clicking of a tab in the tab strip control. My goal is that when they select the PG tab, field EKGRP should be read only; in all other cases it is not. However, despite the fact that the correct nodes are being reached programatically, the actual read only status of the field is not changing. Any help is appreciated.

DATA lo_nd_ui TYPE REF TO if_wd_context_node.

DATA lo_nd_tabs_update TYPE REF TO if_wd_context_node.

DATA lo_el_tabs_update TYPE REF TO if_wd_context_element.

DATA lv_selected_tab TYPE string.

lo_nd_ui = wd_context->get_child_node( name = wd_this->wdctx_ui ).

lo_nd_tabs_update = lo_nd_ui->get_child_node( name = wd_this->wdctx_tabs_update ).

lo_el_tabs_update = lo_nd_tabs_update->get_element( ).

" get the selected tab

lo_el_tabs_update->get_attribute(

EXPORTING name = `SELECTED_TAB`

IMPORTING value = lv_selected_tab ).

CASE lv_selected_tab.

WHEN 'TAB_PG'.

wd_this->gr_sel_helpr->upd_selection_field( i_id = 'EKGRP' i_read_only = abap_true ).

WHEN 'TAB_GR'.

wd_this->gr_sel_helpr->upd_selection_field( i_id = 'EKGRP' i_read_only = abap_false ).

WHEN 'TAB_UP'.

wd_this->gr_sel_helpr->upd_selection_field( i_id = 'EKGRP' i_read_only = abap_false ).

WHEN 'TAB_GG'.

wd_this->gr_sel_helpr->upd_selection_field( i_id = 'EKGRP' i_read_only = abap_false ).

ENDCASE.

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Closing.

former_member189058
Active Contributor
0 Kudos

Hi Robert,

Where have you written this code and the code where you initially add the select options.

Regards,

Reema.

Former Member
0 Kudos

I am doing a standard component usage. In the view controller, I am adding the select options interface and in the wddoinit, I instantiate as well as create the fields for the component.

Former Member
0 Kudos

Hi reema,

I have one Reqirement as like urs , I Created one view container and the view container is embedded with the select-options(select options contains two fields Register Number ,Register Date).

When I check the check box, the Register date(EBDAT) field select-option should get disable.

I tried to update the select option using

wd_this->m_handler->upd_selection_field(

i_id = 'EBDAT'

i_read_only = abap_true ).

But the field is still enable. Can u find any solution on this? If so please guide me.

Regards,

Bala.

Former Member
0 Kudos

Hi,

Please check out the link for my reply -

Try to implement the Memory ID to achieve this.

Regards,

Lekha.

Former Member
0 Kudos

I have read through the thread you linked and others trying various fixes but have not yet come to a solution. The boggling thing about it is that the following code, put in the wddomodifyview, works:

wd_this->gr_sel_helpr->upd_selection_field( i_id = 'EKGRP' i_read_only = abap_true ).

gr_sel_helpr is a global reference that I set after initially creating the select options fields.

However, after the page load subsequent calls running the code above will fail. For example:


  CASE lv_selected_tab.
    WHEN 'TAB_PG'.
      wd_this->gr_sel_helpr->upd_selection_field( i_id = 'EKGRP' i_read_only = abap_true ).
    WHEN 'TAB_GR'.
      wd_this->gr_sel_helpr->upd_selection_field( i_id = 'EKGRP' i_read_only = abap_false ).
    WHEN 'TAB_UP'.
      wd_this->gr_sel_helpr->upd_selection_field( i_id = 'EKGRP' i_read_only = abap_false ).
    WHEN 'TAB_GG'.
      wd_this->gr_sel_helpr->upd_selection_field( i_id = 'EKGRP' i_read_only = abap_false ).
  ENDCASE.

By default, TAB_PG is the value and it does indeed set the EKGRP field to read-only. After switching tabs, any of the other three nodes can be reached (and are as I have verified via debugger) yet they do not change the rendered read-only property on screen despite passing the correct values to the upd_selection_field method.

Former Member
0 Kudos

Update:

After stepping through the debugger, it appears as though you CANNOT change the read-only property. Notice the is_changeable_property flag which is NOT set for read-only and is later checked.


  if i_read_only is supplied.
    <field>-m_read_only               = i_read_only.
  endif.
  if i_explanation is supplied.
    <field>-m_explanation             = i_explanation.
  endif.
  if i_tooltip is supplied.
    <field>-m_tooltip                 = i_tooltip.
  endif.
  if i_is_nullable is supplied.
    <field>-m_is_nullable              = i_is_nullable.
    is_changeable_property = abap_true.
  endif.
  if i_format_properties is supplied.
    <field>-m_format_properties        = i_format_properties.
    is_changeable_property = abap_true.
  endif.

  read table mt_fields assigning <original_field>
        with key m_id = <field>-m_id.
  assert sy-subrc = 0.
  read table mt_added_fields
       with key m_id = <field>-m_id
       assigning <added_field>.
  if sy-subrc = 0.
     <added_field> = <field>.
* if field is a new added field, any property can be changed
    <original_field> = <field>.
  else.
    if is_changeable_property = abap_true.
      delete mt_changed_fields where table_line = <field>-m_id.
      insert <field>-m_id into table mt_changed_fields.
* if field is not new only a subset of properties can be changed
      <original_field>-mt_range_table = <field>-mt_range_table.
      <original_field>-mt_value_set  = <field>-mt_value_set.
      <original_field>-m_is_nullable = <field>-m_is_nullable.
      <original_field>-m_format_properties = <field>-m_format_properties.
    endif.
  endif.

Former Member
0 Kudos

Have you got it or not.

Former Member
0 Kudos

I'd like to follow up with a 2nd question regarding the select options component. By making a parameter field obligitory, the message manger is indeed displaying errors should a null value be present.

My question is, I am having trouble understanding exactly how to control processing around this error message. Take for instance the example above. I'd like for three of the parameters to be required out of 6. Should the user not enter values, I would not continue processing (which in this case would be table selects based off the inputs). However, my traditional way of handling isn't working since the global message manager I am using does not know of the errors (I assume the instantiated component has its own instance of the message manager). I have tried using some of the helper functions and none of them seem to be working (check parameters, check selection screen).