on 10-30-2007 7:27 PM
Hello,
I have a drop down box mapped to a field in the context, the field has some domain values and are populated in the run time. but I have to add another top row '-Select-' indicating to the client that the field need to be selected.
To add 'Select', I can write a method in the WDDOINIT method of the controller and also loop through the domain values and append to the drop down box. But I don't want to do too much of d/b interaction, as the fields are anyway loaded to the dropbox by mapping.
Is there a way in web dynpro, that we could do like in normal ABAP reports, to Loop at the screen and identify all the drop down boxes and add a 'select' row at the top?
I really appreciate any help.
Thank you
KV.
Hi,
you can do that fairly easy:
1. node = wd_context->get_child_node( name ).
2. node_info = node->get_node_info().
3. ls_attribute_info = node_info->get_attribute(name attribute).
4. lt_valueset = ls_attribute_info-VALUE_SET
5. append value to lt_valueset + sort
6. node_info->set_attribute_value_set( name attribute + lt_valueset).
grtz,
Koen
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
As there is no "GET_ATTRIBUTE_VALUE_SET" or "ADD_ATTRIBUTE_VALUE", you have to take the domain fixed values by another means, and convert them to the WD value set format (including the Select value).
Check out this code which would be put in the WDDOINIT method of the view:
METHOD wddoinit .
*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
* A.Bindi
* DropDownByKey test
* Context Structure:
* CONTEXT (Root node)
* |_TEST (String attribute)
*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
CONSTANTS: BEGIN OF lk_default_val,
value TYPE wdr_context_attr_value-value
VALUE '0',
text TYPE wdr_context_attr_value-text
VALUE 'Select...',
END OF lk_default_val.
DATA: lwa_dm_value TYPE dd07v,
lt_dm_values LIKE TABLE OF lwa_dm_value,
lwa_wd_value TYPE wdr_context_attr_value,
lt_wd_values LIKE TABLE OF lwa_wd_value,
lr_node_info TYPE REF TO if_wd_context_node_info,
lr_element TYPE REF TO if_wd_context_element.
* Get Domain Fixed Values
CALL FUNCTION 'DD_DOMVALUES_GET'
EXPORTING
domname = 'YDM_TEST'
text = abap_true
TABLES
dd07v_tab = lt_dm_values
EXCEPTIONS
wrong_textflag = 1
OTHERS = 2.
CHECK sy-subrc = 0.
* Convert them to Web Dynpro Valueset format,
* appending the "Select..." line first
APPEND lk_default_val TO lt_wd_values.
LOOP AT lt_dm_values INTO lwa_dm_value.
lwa_wd_value-value = lwa_dm_value-domvalue_l.
CONDENSE lwa_wd_value-value.
lwa_wd_value-text = lwa_dm_value-ddtext.
APPEND lwa_wd_value TO lt_wd_values. CLEAR lwa_wd_value.
ENDLOOP.
* Set attribute valueset
lr_node_info = wd_context->get_node_info( ).
lr_node_info->set_attribute_value_set(
name = 'TEST'
value_set = lt_wd_values
).
* Set attribute's default as 0 ("Select...")
lr_element = wd_context->get_element( ).
lr_element->set_attribute(
value = lk_default_val-value
name = `TEST`
).
ENDMETHOD.
I think this is the only way to achieve this. In case you do it, you should change the "Input Help Mode" of the context attribute to Deactivated as otherwise the framework will be loading values which you'll overwrite with this, reducing performance because of the repeated data fetching.
Regards
EDIT: Note that using the DOMVALUE_L field, you have to be sure that the number you use for the select line (0 in this case) is not already used by some value.
You'll obviously have to adapt this code for the domain you're using and your context structure, most probably you have some subnode you'll have to get first and the attribute name will change from 'TEST' to yours.
Message was edited by:
Alejandro Bindi
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Kiran
add one more value for ur dropdown by key
key-> 'Select'
value-> 'Select'
in the 'init' method where u write the code for dropdown by key
set the value to select for ur UI to 'Select' and manage your code
Hope this will solve ur problem
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Koen,
Appreciate your quick response, but your solution would work just fine if the object is either a 'input' field ot any single selection object. In my case the object is 'dropdownbyKey' and has multiple values in the list.
So, while doing your third step
'ls_attribute_info = node_info->get_attribute(name attribute).', this gave an error, so I changed it to
'lo_node_attribute->get_attribute( EXPORTING name = `TEST1`
IMPORTING value = ls_stat )'
TEST1 is the element of the node which is mapped to the dropdownbykey object. TEST1 is the field which has some values in its domain.
After that step, ls_stat has nothing in it. I wish that field would be loaded with all the domain values.
Also, in which method should I be doing this? in component controller methods or View methods?
____________________________________________________________________
Sorry for not explaining it properly, I'll try explaining it again.
I have a 'Dropdown by Key' object on a WebDynPro VIEW which is mapped to a field in the context. That field has data domain values of 'Yes' and 'No'.
So, in the run time, that dropdown by Key object is loaded with 'Yes' and 'No' values. All that I wanted to do is add '-Select-' to this list(that would be displayed in the dropdown box).
I cannot add '-Select-' to the domain values, I wanted to add this value to the list either in the component controller method or view method.
I would really appreciate if you can suggest any ideas to this.
Thank you
Kiran.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Kiran,
See what can be done is just add -SELECT- as one of your domain values. So your domain definition will be char 8.
Fix.Val Short Description
-SELECT- -SELECT-
YES YES
NO NO
Then in the your context node property ( one whch contains attribute whose type will be of data element containing the above domain ) mention the default value as -SELECT-
When you try to do it through program ie adding an additional -SELECT- on the fixed vaules (ie YES and NO in this case) it may not be possible reason might be since it is a fixed value domian it can take only the values being mentioned in the domain.
Regards
Jithesh
User | Count |
---|---|
87 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.