cancel
Showing results for 
Search instead for 
Did you mean: 

Drop down by key data binading

former_member654348
Participant
0 Kudos

HI

I am new to webdynpro ABAP. My requirement is, user should be able to select multiple values in dropdown. I came to know that it can be done using drop down by key. Can anybody explain how to do data binding and fetch the selected data from dropdown by key. I was searching in the forum, but didnot get any helpful answer.Your inputs would be really helpful.

Thanks,

Pallavi.

Accepted Solutions (1)

Accepted Solutions (1)

JanarthananE
Contributor
0 Kudos

Hi pallavi,

Refer the following thread for better understanding about dropdown by key.

http://scn.sap.com/thread/556251

Hope its useful to u,

Regards

Jana

former_member654348
Participant
0 Kudos

Hi,

Thanks for your replies. I tried implementing it. But when I run the application, it is giving dump saying, that node doesnot contain any elements.

My context node is like this -

Mainnode->subnode(cardinaity 0 to n) ->attribute value, attribute text.

I am binding attribute text value to screen element.

Please find my code below.

   DATA lo_nd_cn_cuase TYPE REF TO if_wd_context_node.
  DATA lo_el_cn_cuase TYPE REF TO if_wd_context_element.
  DATA ls_cn_cuase TYPE wd_this->element_cn_cuase.
   DATA wa_code like LINE OF int_code.
* navigate from <CONTEXT> to <CN_CUASE> via lead selection
  lo_nd_cn_cuase = wd_context->path_get_node( path = `CN_REQUESTDETAILS.CN_CUASE` ).
* get element via lead selection
  lo_el_cn_cuase = lo_nd_cn_cuase->get_element( ).

  data wd_node_info type ref to if_wd_context_node_info.
  data value_set type wdr_context_attr_value_list.
  data: lv_value TYPE WDR_CONTEXT_ATTR_VALUE.

LOOP AT int_code INTO wa_code.
      MOVE wa_code-code TO lv_value-value.
      MOVE wa_code-KURZTEXT TO lv_value-text.
      APPEND lv_value to value_s

   DATA lo_nd_cn_cuase TYPE REF TO if_wd_context_node.
  DATA lo_el_cn_cuase TYPE REF TO if_wd_context_element.
  DATA ls_cn_cuase TYPE wd_this->element_cn_cuase.
   DATA wa_code like LINE OF int_code.
* navigate from <CONTEXT> to <CN_CUASE> via lead selection
  lo_nd_cn_cuase = wd_context->path_get_node( path = `CN_REQUESTDETAILS.CN_CUASE` ).
* get element via lead selection
  lo_el_cn_cuase = lo_nd_cn_cuase->get_element( ).

  data wd_node_info type ref to if_wd_context_node_info.
  data value_set type wdr_context_attr_value_list.
  data: lv_value TYPE WDR_CONTEXT_ATTR_VALUE.

LOOP AT int_code INTO wa_code.
      MOVE wa_code-code TO lv_value-value.
      MOVE wa_code-KURZTEXT TO lv_value-text.
      APPEND lv_value to value_set.
    ENDLOOP.
  wd_node_info = lo_nd_cn_cuase->get_node_info( ).

   wd_node_info->set_attribute_value_set( name = 'CA_CAUSE_TXT'
                                          value_set = value_set ).

Former Member
0 Kudos

Hi Nagapallavi,

Do one thing create node and subnode with one attribute type string only.and maintain and maintain cardin  0...n.

According to u r node replace node name ...

   DATAlo_nd_context TYPE REF TO if_wd_context_node,
          lo_nd_dropdwn TYPE REF TO if_wd_context_node_info.

*Beach Is Node Name...Here u place u r node name.

      lo_nd_context = wd_context->get_child_node( 'BEACH' ).

      lo_nd_dropdwn = lo_nd_context->get_node_info( ).

*    Initially assign NULL value to dropdown

    lo_nd_context->bind_element( EXPORTING  new_item = ls_beach_hut   set_initial_elements = abap_false ).

      DATA  ls_beach_hut   TYPE wd_this->element_beach_hut.
    lo_nd_context = wd_context->get_child_node( 'BEACH' ).
*    Initially assign NULL value to dropdown
    lo_nd_context->bind_element( EXPORTING  new_item = ls_beach_hut   set_initial_elements = abap_false ).

    LOOP AT lt_name INTO ls_name.
    ls_key-value = ls_name-code.
    ls_key-text = ls_name-name.
    APPEND ls_key TO lt_key.

  lo_nd_dropdwn->set_attribute_value_set( name = 'KEY' value_set = lt_key ).

Regards,

Venkat.

former_member654348
Participant
0 Kudos

Hi Venkat,

Thanks a lot. That dump issue is resolved and i am able to populate data to dropdown.

I have a few quries here.

1. How do I select multiple entries and capture the selected values?

2. Once get selected data, that needs to be stored in backed. and in next step, need to display the selected entries.(Mean, the entries selected in previous step need to be showed as selected).

Thanks,

Pallavi.

JanarthananE
Contributor
0 Kudos

Hi Pallavi,

Refer the following link for step by step process to select multiple values in dropdown.

http://www.saptechnical.com/Tutorials/WebDynproABAP/Listbox/page1.htm

Hope its useful to u,

Regards

Jana

Former Member
0 Kudos

Hi Nagapallavi,

When u select data then in context u will get code value that is selected text value.... Thse values normally we stord in master tables.

like below

value      text

100          abc

200          def

in dropdown we can see text values( abc,def)   when u select abc then the value is come  '100' in context..Here w e have to read context value  means '100'..  depending up on these values we can get text from tables..and in data base we can save to header and details table......

regards,

Venkat

former_member654348
Participant
0 Kudos

Hi

I need to select a value (set lead selection index incase of drop down by index) of drop down by key.

How can i achieve it? In dropwodn by index case i can do it like - fetch all the values using get_static_attributes_table and then do set_lead_selection_Index.

Bot how about it incase of DD by key? whenI use get_static_attributes_table, it is not etching the values.

Thanks,

Pallavi.

Answers (1)

Answers (1)

chengalarayulu
Active Contributor
0 Kudos