cancel
Showing results for 
Search instead for 
Did you mean: 

How to restrict values from DropDown by Key

Former Member
0 Kudos

Hi All,

I have a list of values in my DropDown by Key UI element which are maintained in domain level.

but my requirment is i dont want show one of the value from the dropdown list,

can you please help me ..

Thanks,

Raj.

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi,

U Can use the Following Code for restricting the Domain Values.

DATA lo_nd_dropdown TYPE REF TO if_wd_context_node.
  DATA lo_el_dropdown  TYPE REF TO if_wd_context_element.
  DATA lt_dropdown       TYPE wd_this->elements_dropdown.
  DATA ls_dropdown      TYPE wd_this->element_dropdown.

  DATA lo_nd_info_dropdown TYPE REF TO if_wd_context_node_info.
  DATA el_attr_info               TYPE WDR_CONTEXT_ATTRIBUTE_INFO.

  data: lt_valueset type wdr_context_attr_value_list,
          l_value       type wdr_context_attr_value.

* navigate from <CONTEXT> to <DROPDOWN> via lead selection
  lo_nd_dropdown = wd_context->get_child_node( name = wd_this->wdctx_dropdown ).

  lo_nd_info_dropdown = lo_nd_dropdown->get_node_info( ).


  call method lo_nd_info_dropdown->get_attribute
    EXPORTING
      name           = 'VALUE'
    RECEIVING
      attribute_info = el_attr_info.

  lt_valueset = el_attr_info-value_set.

  delete lt_valueset where <condition>

  lo_nd_info_dropdown->set_attribute_value_set(
  name = 'VALUE'
  value_set = lt_valueset ).

Regards,

Padmam.

alejandro_bindi
Active Contributor
0 Kudos

I may add something: You should also change the Input Help Mode determination on the context attribute to Deactivated. That way you avoid the unnecesary loading of the Domain values by the framework increasing the performance slightly.

Regards

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

Well then you are going to have to replace the value population from the Domain with one from a Value_Set. For more details on how you use a VALUE_SET to populate the allowed values in a DropDownByKey, please see the online help:

http://help.sap.com/saphelp_nw70ehp1/helpdata/en/bb/69b441b0133531e10000000a155106/frameset.htm

So you will need to read all the current DDic Domain Values from the Data Dictionary into an internal table. You can then delete the one you don't want. You then set this internal table into the context attribute as its VALUE_SET using the example code (method IF_WD_CONTEXT_NODE_INFO=>SET_ATTRIBUTE_VALUE_SET) from the help link.