cancel
Showing results for 
Search instead for 
Did you mean: 

filling dropdown by key

Former Member
0 Kudos

Hi Experts,

I have a WebDypro for ABAP application with a UI Element DropdownByKey. I want to get the values to select from a DDIC table, but I have to fill the dropdown list in a method. How can I do that? I can not use a DDIC search aid. I have to get the content of the DDIC table manually.

I know, that I have to give the data of the table to my context attribute, but how?

Can someone support me with some example code?

Thanks a lot!

Best regards,

Ingmar

Accepted Solutions (1)

Accepted Solutions (1)

abhimanyu_lagishetti7
Active Contributor
0 Kudos

data: lt_valueset type table of wdr_context_attr_value,

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.

lr_node = wd_context->get_child_node( '<node name>' ).

lr_nodeinfo = lr_node->get_node_info( ).

  • get the database table values into internal table and fill lt_valueset like the example

ls_valueset-value = '1'.

ls_valueset-text = 'TESTO'.

append ls_valueset to lt_valueset.

lr_nodeinfo->set_attribute_value_set(

exporting

name = '<context attribute name>'

value_set = lt_valueset ).

Abhi

Answers (4)

Answers (4)

Former Member
0 Kudos

Hi Ingmar,

This is my dropdown coding , here iam using dropdown by Key .In initialization i wrote d code.

node : cardinality 1:1

selection 0:1

data lo_nd_org_object type ref to if_wd_context_node.

data lo_nd_info_org_object type ref to if_wd_context_node_info.

data lo_el_org_object type ref to if_wd_context_element.

data ls_org_object type wd_this->element_org_object.

data value_set type wdr_context_attr_value_list.

data wa_value_set type wdr_context_attr_value.

data it_list type standard table of zstr_details.

data wa_list type zstr_details.

navigate from <CONTEXT> to <ORG_OBJECT> via lead selection

lo_nd_org_object = wd_context->get_child_node( name = wd_this->wdctx_org_object ).

lo_nd_info_org_object = lo_nd_org_object->get_node_info( ).

call function 'ZBAPI_ORG_LIST'

tables

et_list = it_list

.

loop at it_list into wa_list.

wa_value_set-value = wa_list-org_type.

wa_value_set-text = wa_list-org_desc.

append wa_value_set to value_set.

clear: wa_list,

wa_value_set.

endloop.

lo_nd_info_org_object->set_attribute_value_set( name = 'ORG_TYPE' value_set = value_set ).

read table value_set into wa_value_set index 1.

Reward if useful

Regards,

Muneesh Gitta.

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

Well we know who the fastest typist (or the least distracted) is now.

abhimanyu_lagishetti7
Active Contributor
0 Kudos

All for a noble cause

Points for U.N. World Food Programme

Abhi

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

You need to use the IF_WD_CONTEXT_NODE_INFO=>SET_ATTRIBUTE_VALUE_SET to load the allowed values into the attribute that you bind to the selectedKey property of the DropDownByKey. Here is the help document on the topic:

http://help.sap.com/saphelp_nw70/helpdata/EN/bb/69b441b0133531e10000000a155106/frameset.htm

data l_activities type zpm_activity_typ_tbl.
  l_activities = wd_assist->read_all_activities( ).
  data lt_valueset type wdr_context_attr_value_list.
  field-symbols <wa_act> like line of l_activities.
  field-symbols <wa_vs>  like line of lt_valueset.

  loop at l_activities assigning <wa_act>.
    append initial line to lt_valueset assigning <wa_vs>.
    <wa_vs>-value = <wa_act>-activity_type.
    <wa_vs>-text  = <wa_act>-activity_desc.
  endloop.



  data lo_nd_meeting type ref to if_wd_context_node.
* navigate from <CONTEXT> to <MEETING> via lead selection
  lo_nd_meeting = wd_context->get_child_node( name = wd_this->wdctx_meeting ).
  data lo_node_info type ref to if_wd_context_node_info.
  lo_node_info = lo_nd_meeting->get_node_info( ).
  lo_node_info->set_attribute_value_set(
     name = 'ACTIVITY_TYPE'
     value_set = lt_valueset ).

Former Member
0 Kudos

Hi

Have a look at this code

method WDDOINIT .
  data:
    lr_node                      type ref to If_Wd_Context_Node.
  
  data : lr_nodeinfo type ref to if_wd_context_node_info,
  lt_valueset type wdr_context_attr_value_list,
  ls_valueset type wdr_context_attr_value,
  WA TYPE SPFLI.

  lr_node = wd_context->get_child_node( 'DROP_DOWN' ).
  lr_nodeinfo = lr_node->get_node_info( ).
* USE UR TABLE AND FILL ACCORDINGLY 
  SELECT * FROM SPFLI INTO WA.
      ls_valueset-value = 'key1'.   " actual values
      ls_valueset-text = WA-CARRID. " text displaying on the dropdown
      append ls_valueset to lt_valueset.
  ENDSELECT.

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

Hope this helps U.

Thanks and Regards

Tamilselvan.K

Edited by: Tamilselvan K on Jul 23, 2008 4:18 PM