on 2012 Aug 03 4:34 PM
Hi all gurus,
a trivial question probably for many of you, but I'm a bit lost on the task. We have a custom field at position level on an SRM document which has its own domain populated with 5 fixed values (say A,B,C,D and E).
Shortly, we'd like to filter these values on the basis of criteria which is known only @ runtime.
To make an simple example, consider that a document which refers to a specific company should have only A and E as possible values for the custom field.
To further complicate the problem, consider that this custom field is retrieved dynamically in the WDDOMODIFYVIEW method of the view that shows item's detail, so it's not a static entry under the CONTEXT node of the view itself; it's just added dinamically.
By now I was able to obtain the istance type of that custom field, which leads to the use of the methods from DropdownByKey class:
* Retrieve dynamically the istance type and associate an action/method
lr_class_descr ?= cl_abap_typedescr=>describe_by_object_ref( lo_ui_element_attr ).
field_type = lr_class_descr->get_relative_name( ).
case field_type.
...
when 'CL_WD_DROPDOWN_BY_KEY'.
lo_wd_dropdown_by_key ?= lo_ui_element_attr.
lo_wd_dropdown_by_key->SET_ON_SELECT( 'REFRESH' ). /this was added to refresh the view on selection
Given that I've got the elements to build a filter condition, how can I:
- retrieve the values from this dropdownbyKey element;
- re-assign the filtered list to the dropdownbyKey element?
Thanks anyone for your kind help
Hi Matteo,
I didn't try it, but theoretically it should work.
Maybe you want to try it.
Idea is to create an attribute with a filtered value set during runtime and bind it to your DropDownByKey.
...
when 'CL_WD_DROPDOWN_BY_KEY'.
data lt_all_vals type table of DD07V. "All domain values
data ls_all_vals type DD07V.
data lt_filt_vals type WDR_CONTEXT_ATTR_VALUE_LIST. "filtered values
data ls_filt_vals type WDR_CONTEXT_ATTR_VALUE.
data lv_rc like sy-subrc.
">>>>Populate list with values for your DropDownByKey
"Get all domain values (if you need them)
CALL FUNCTION 'DD_DOMVALUES_GET'
EXPORTING
DOMNAME = 'YOUR DOMAIN NAME' "Add your domain name
TEXT = 'X'
LANGU = sy-langu
* BYPASS_BUFFER = ' '
IMPORTING
RC = lv_rc
TABLES
DD07V_TAB = lt_all_vals.
"Filter Values:
loop at lt_all_vals into ls_all_vals.
if <.........>. " Add your filter criteria to add the values you want to see.
ls_filt_vals-values = ls_all_vals-DOMVALUE_L.
ls_filt_vals-text = ls_all_vals-DDTEXT.
append ls_filt_vals to lt_filt_vals.
endif.
endloop.
"<<<<Populate list with values for your DropDownByKey
">>>> create attribute to be bound to selectedKey-property of your DropDownByKey
data: lr_node_info type ref to IF_WD_CONTEXT_NODE_INFO.
DATA: ls_attribute TYPE wdr_context_attribute_info.
lr_node_info = WD_CONTEXT->GET_NODE_INFO( ).
ls_attribute-name = 'ANYUNIQUENAME'.
ls_attribute-type_name = 'YOUR TYPE'. "
ls_attribute-value_help_mode = '0'."Automatisch
ls_attribute-value_set = lt_filt_vals.
"Add attribute to context:
if lr_node_info->HAS_ATTRIBUTE( 'ANYUNIQUENAME' ).
lr_node_info->REMOVE_ATTRIBUTE( 'ANYUNIQUENAME' ).
endif.
lr_node_info->add_attribute(
attribute_info = ls_attribute ).
"bind attribute to your uielement:
lo_wd_dropdown_by_key->BIND_SELECTED_KEY( 'CONTEXT.ANYUNIQUENAME' ).
Hope this helps. Keep me informed.
BR
ismail
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
66 | |
10 | |
10 | |
10 | |
10 | |
8 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.