cancel
Showing results for 
Search instead for 
Did you mean: 

Drop down key

Former Member
0 Kudos

hi

i have drop down key in my layout and using supply function method am trying to fill it ,but am not able to get the value in my drop down box.below is the code.

DATA LO_ND_TIME_NODE TYPE REF TO IF_WD_CONTEXT_NODE.

DATA LO_EL_TIME_NODE TYPE REF TO IF_WD_CONTEXT_ELEMENT.

DATA LS_TIME_NODE TYPE WD_THIS->ELEMENT_TIME_NODE.

DATA LT_TIME_NODE TYPE WD_THIS->ELEMENTS_TIME_NODE.

  • navigate from <CONTEXT> to <TIME_NODE> via lead selection

LO_ND_TIME_NODE = WD_CONTEXT->GET_CHILD_NODE( NAME = WD_THIS->WDCTX_TIME_NODE ).

  • get element via lead selection

LO_EL_TIME_NODE = LO_ND_TIME_NODE->GET_ELEMENT( ).

DATA: HOURS TYPE NUMC2,

MINUTES TYPE NUMC2.

minutes = 60.

hours = 25.

DATA: L_NUM TYPE NUMC2.

DO HOURS TIMES.

L_NUM = SY-INDEX - 1.

LS_TIME_NODE-HOURS = L_NUM.

APPEND LS_TIME_NODE TO LT_TIME_NODE.

ENDDO.

DO MINUTES TIMES.

L_NUM = SY-INDEX - 1.

LS_TIME_NODE-MINUTES = L_NUM.

APPEND LS_TIME_NODE TO LT_TIME_NODE.

ENDDO.

node->bind_table(

new_items = LT_TIME_NODE

set_initial_elements = abap_true ).

Thanks

Ganesh

Accepted Solutions (1)

Accepted Solutions (1)

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

If this is a DropDownByKey, then you don't populate the possible values in such a way. This would be an approach for DropDownByIndex perhaps. For dropDownByKey you must populate the value_set of the context attribute. See this help link for more details:

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

Answers (3)

Answers (3)

Former Member
0 Kudos

Thanks to you all

Former Member
0 Kudos

hi,

refer to this example wdr_test_events......view dropdownbyidx and dropdownbykey

and method name is onactionselect.

former_member402443
Contributor
0 Kudos

Hi Ganesh,

You can fill value in dropdownbykey as given below

data:

lt_valueset type table of wdr_context_attr_value,

ls_valueset like line of lt_valueset,

ls_valueset type wdr_context_attr_value,

lr_node type ref to if_wd_context_node,

lr_nodeinfo type ref to if_wd_context_node_info.

ls_valueset-key = '1'.

ls_valueset-value = 'FirstName'.

append ls_valueset to lt_valueset.

ls_valueset-key = '2'.

ls_valueset-value = 'SecondName'.

append ls_valueset to lt_valueset.

ls_valueset-key = '3'.

ls_valueset-value = 'ThirdName'.

append ls_valueset to lt_valueset.

" node name is candidate with Attribute REG_ST

" so my dropdown for key appears for UI element binded for REG_ST

lr_node = wd_context->get_child_node( name = if_componentcontroller=>wdctx_candidate ).

lr_nodeinfo = lr_node->get_node_info( ).

lr_nodeinfo->set_attribute_value_set(

exporting

name = 'REG_ST'

value_set = lt_valueset ).

or u can set the values in the value range of the domain of the data element that u have taken for the attribute. In this case u don't need any code to populate the values in the drop down box.

Regards

Manoj Kumar

Former Member
0 Kudos

Hi Ganesh,

The way you get the dropdown by key is illustrated in the below code snippet adjust as per your requirement.

data:
   lt_valueset type table of wdr_context_attr_value,
   ls_valueset like line of lt_valueset,
   ls_valueset type wdr_context_attr_value,
   lr_node type ref to if_wd_context_node,
   lr_nodeinfo type ref to if_wd_context_node_info.

   ls_valueset-key = '1'.
   ls_valueset-value = 'FirstName'. 
   append ls_valueset to lt_valueset.

   ls_valueset-key = '2'.
   ls_valueset-value = 'SecondName'. 
   append ls_valueset to lt_valueset.

   ls_valueset-key = '3'.
   ls_valueset-value = 'ThirdName'. 
   append ls_valueset to lt_valueset.

 " node name is candidate with Attribute REG_ST 
 " so my dropdown for key appears for UI element binded for REG_ST 
  lr_node = wd_context->get_child_node( name = if_componentcontroller=>wdctx_candidate ).
  lr_nodeinfo = lr_node->get_node_info( ).
  lr_nodeinfo->set_attribute_value_set(
  exporting
  name = 'REG_ST'
  value_set = lt_valueset  ).

Regards

Prashant

P.S. Points welcome

Former Member
0 Kudos

Hi,

i have already tried in the same fashion,but am facing the cardinality problem.

The following error text was processed in the system SD1 : Adapter error in &VIEW_ELEMENT_TYPE& "HH_INP1" of view "Z243_SIP.MAIN": Context binding of property SELECTED_KEY cannot be resolved: Node MAIN.1.TIME_NODE does not contain any elements 
The error occurred on the application server sapecc6sd1_SD1_00 and in the work process 2 .

The termination type was: RABAX_STATE

i have set my cardinality as 0:n in my supply function .

I have a doubt whether it is required to bind to the parameter NODE of my supply function method

data:

lt_valueset TYPE WDY_KEY_VALUE_TABLE,

ls_valueset TYPE WDY_KEY_VALUE,

lr_node type ref to if_wd_context_node,

lr_nodeinfo type ref to if_wd_context_node_info.

lr_node = wd_context->get_child_node( name = if_componentcontroller=>wdctx_time_node ).

lr_nodeinfo = lr_node->get_node_info( ).

DATA: HOURS TYPE NUMC2,

MINUTES TYPE NUMC2.

minutes = 60.

hours = 25.

DATA: L_NUM TYPE NUMC2.

DO HOURS TIMES.

L_NUM = SY-INDEX - 1.

ls_valueset-key = L_NUM.

ls_valueset-value = L_NUM.

append ls_valueset to lt_valueset.

ENDDO.

lr_nodeinfo->set_attribute_value_set(

exporting

name = 'HOURS'

value_set = lt_valueset ).

CLEAR LT_VALUESET.

DO MINUTES TIMES.

L_NUM = SY-INDEX - 1.

ls_valueset-key = L_NUM.

ls_valueset-value = L_NUM.

append ls_valueset to lt_valueset.

ENDDO.

lr_nodeinfo->set_attribute_value_set(

exporting

name = 'MINUTES'

value_set = lt_valueset ).

Former Member
0 Kudos

Hi Ganesh,

Cardinality may be problem . You try setting cardinality as 1..N instead of 0..N.

However one main point you DONT need to put the SOURCE in the supply function. You can

simply put this SOURCE in any METHOD and ensure that you call it inside WDDOINIT( )of

the view having this DropDownByKey. Thus in effect anytime before you display the view

having DropDownKey you should have called your method that constructs the value for the DDK.

Greetings

Prashant

Edited by: Prashant on Feb 11, 2009 12:34 PM

Former Member
0 Kudos

Hi Prashanth,

i have tried with all cardinality setup,but am not getting any value in my drop down box.

Is it required to call my supply function method inside the view's WD_INIT( )?

Thnks

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

I think you need to read through the links and examples again. You shouldn't need a supply function at all to populate the value set of a drop down by key. You are defintely on the wrong path there.

Former Member
0 Kudos

Hi Ganesh ,

You dont require Supply Function. All you need is set the cardinality 1..N and one method that executes the SOURCE you wrote also pasted below. Ensure that you call that method in your view WDDOINIT( ). Nothing to be added to supply funtion at all!!

data:
lt_valueset TYPE WDY_KEY_VALUE_TABLE,
ls_valueset TYPE WDY_KEY_VALUE,
lr_node type ref to if_wd_context_node,
lr_nodeinfo type ref to if_wd_context_node_info.

lr_node = wd_context->get_child_node( name = if_componentcontroller=>wdctx_time_node ).
lr_nodeinfo = lr_node->get_node_info( ).



DATA: HOURS TYPE NUMC2,
MINUTES TYPE NUMC2.

minutes = 60.
hours = 25.

DATA: L_NUM TYPE NUMC2.

DO HOURS TIMES.
L_NUM = SY-INDEX - 1.
ls_valueset-key = L_NUM.
ls_valueset-value = L_NUM.
append ls_valueset to lt_valueset.
ENDDO.


lr_nodeinfo->set_attribute_value_set(
exporting
name = 'HOURS'
value_set = lt_valueset ).

CLEAR LT_VALUESET.
DO MINUTES TIMES.
L_NUM = SY-INDEX - 1.
ls_valueset-key = L_NUM.
ls_valueset-value = L_NUM.
append ls_valueset to lt_valueset.
ENDDO.

lr_nodeinfo->set_attribute_value_set(
exporting
name = 'MINUTES'
value_set = lt_valueset ).