cancel
Showing results for 
Search instead for 
Did you mean: 

Passing a value from one dropdown to another dropdown

former_member206441
Contributor
0 Kudos

Dear Experts,

Im having two views with a dropdownbyindex ui element per view.

im displaying values in both the dropdown box by writing supply function. when i select a value in a dropdown box in second view the selected value is passed to first view.

My requirement is to show the value which is selected in the second view dropdown box to first view dropdown box.

but the values in the two dropdown box are different , i tried by appending the selected value to the first dropdown.

It is not working.

Can anyone help me regarding this issue?

Thanks & Regards

Arun.P

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

hi Arun ,

u can pass value of a attribute using wd_comp_controller

1 create context attributes for ur two dropdowns under node in ur component controller

2 make a Attribute of type string , say attr1 ,under the ATTRIBUTE tab in component controller .

3 in ur second view , read the value entered by the user , using get_attribute method . u can do this by reading the context node let us say cn_gddb and attribute under it is ca_gddb which is binded to the dropdown

using code wizard or pressing CNTRL + F7

and selecting the radio button , read context node/attribute , let us say u obtain value val1


  DATA lo_nd_cn_gddb TYPE REF TO if_wd_context_node.
    DATA lo_el_cn_gddb TYPE REF TO if_wd_context_element.
    DATA ls_cn_gddb TYPE wd_this->element_cn_gddb.
    DATA val1 LIKE ls_cn_gddb-ca_gddb.
*   navigate from <CONTEXT> to <CN_GDDB> via lead selection
    lo_nd_cn_gddb = wd_context->get_child_node( name = wd_this->wdctx_cn_gddb ).

*   get element via lead selection
    lo_el_cn_gddb = lo_nd_cn_gddb->get_element(  ).

*   get single attribute
    lo_el_cn_gddb->get_attribute(
      EXPORTING
        name =  `CA_GDDB`
      IMPORTING
        value = val1 ).

4 pass this value to attr1 , using


wd_Comp_controller->attr1 = val1

5 add this value to the internal table which is binded to the drop down by index in ur first view

U wud b able to achieve the desired functionality . I hope it shud help u

regards,

amit

Edited by: amit saini on Oct 20, 2009 7:46 AM

former_member206441
Contributor
0 Kudos

Hi Amit

im getting the selected value in a attribute, but i dont know how to append the value to internal table.

Thanks & Regards

Arun.P

Former Member
0 Kudos

hi,

1.suppose you read the value from comp controller :

lv_st = wd_comp_controller->Att1.

Now inside the supply function :

2. Make an work area of type table.

wa_area-field = lv_str.

3. Append work area to internal table.

append wa_area to it_tab.

4. bind the internal table to node.

lo_nd->bind_table( it_tab)

it_tab is the internal table binded to node of dropdown by index.

wa_area - Work area of type internal table.

lv_str - Selected Value of dropdown 2.

lo_nd - Instance of node binded to dropdown1.

Ex :

DATA lo_nd_node_flighttab TYPE REF TO if_wd_context_node.

DATA it_tab TYPE wd_this->elements_node_flighttab.

DATA wa_area TYPE wd_this->element_node_flighttab.

lo_nd_node_flighttab = wd_context->get_child_node( name = wd_this->wdctx_node_flighttab ).

wa_area-Field = wd_comp_controller->Att1.

append wa_area to it_tab.

lo_nd_node_flighttab->bind_table( exporting NEW_ITEMS = it_tab SET_INITIAL_ELEMENTS = ABAP_FALSE ).

former_member190818
Active Contributor
0 Kudos

Hi Arun,

As normal, you can append values from attribute to internal table and dont forget to bind the appended internal table. By this way, you should get the value in that dropdown list.

Regards,

JMB

Former Member
0 Kudos

hi ,

u need to get the value in ur internal table and bind the internal table to the context nnode of ur 1 st view , by taking reference


*  internal table declarations
*  DATA :it_sites TYPE STANDARD TABLE OF z2ts_sites .
* work area declaration 
*        wa_sites TYPEz2ts_sites .

wa_sites-sitedescription = wd_comp_controller->attr1
APPEND wa_sites to it_sites

thereafter read the context node using code wizard and bind the internal table using bind_table in ur supply function


 DATA: lo_nd_cn_sitedescription TYPE REF TO if_wd_context_node,
       lo_el_cn_sitedescription TYPE REF TO if_wd_context_element,
        ls_cn_sitedescription TYPE wd_this->element_cn_sitedescription.
*    navigate from <CONTEXT> to <CN_SITEDESCRIPTION> via lead selection
  lo_nd_cn_sitedescription = wd_context->get_child_node(
name = wd_this->wdctx_cn_sitedescription ).

  lo_nd_cn_sitedescription->bind_table( it_sites ).

regards,

amit

former_member206441
Contributor
0 Kudos

Hi Sourav and JMB,

Sorry, i mentioned as 2 views, but actually it is a single view and a popup. when i click the popup view's dropdown box

the value is sent to first view, its ok but when a first view refresh occurs then only the code inside supply function will execute. But my scenario is when i select a value in dropdown in a popup the value should be appended to first view's dropdown.

Thanks & Regards,

Arun.P

Former Member
0 Kudos

write this piece of code ( as explained earlier inmy second reply to the thread) in OnactionOk method of ur popup

Former Member
0 Kudos

hi Arun,

Just add this code to your supply function .

1. Read the comp controller attribute which has value of dropdown 2.

2. Have that value into a work area.

3. Check whether work area has some value or not.

4. If work area has some value add it to internal table , otherwise not.

DATA lo_nd_node_flighttab TYPE REF TO if_wd_context_node.

DATA it_tab TYPE wd_this->elements_node_flighttab.

DATA wa_area TYPE wd_this->element_node_flighttab.

lo_nd_node_flighttab = wd_context->get_child_node( name = wd_this->wdctx_node_flighttab ).

wa_area-Field = wd_comp_controller->Att1.

if wa_area is not initial.

append wa_area to it_tab.

endif.

lo_nd_node_flighttab->bind_table( it_tab ).

In your case , as supply function will not trigger then you can write this code when you close the pop-up.

former_member206441
Contributor
0 Kudos

Dear Sourav,

Thank You for your valuble suggestion, now im able to get the value from popup to first view dropdownbox.

Thanks & Regards

Arun.P

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi Arun,

Seems there is some problem with the display of code using

 

Please copy the code to the notepad and then check.

Regards,

-Syed.

Former Member
0 Kudos

Hi Arun,

I'll give you my scenario as how I worked on the same.

As you said, for both the dropdowns, the values will be fetching using the supply functions.

--> Instead of this, let the values for the first dropdown be coming from the supply function, and depending on the selected item of the first drop down, send the related values to the second drop down, let them be on same view or different views.

Let us say, I've filled my first dropdown. And now, On Action of selection of an Item of the same drop down, I'll get the relative values from a Z class, or a select query. Then after your internal table is filled up, using that you can work accordingly.

If you can insert the context node of the second dropdown, will make your process more easier.

If you look at my below code, i'm retrieving the values corresponding to the action of first drop down for second drop down.

 data:lt_attributes type standard table of if_main=>element_dropdown2,
           wa_attributes like line of lt_attributes.
 data ls_dropdown1 type wd_this->element_dropdown1.
   data ls_dropdown2 type wd_this->element_dropdown2.
 data lv_action_1 like ls_dropdown2-action_1.
   data lv_action     like ls_dropdown1-action.
 field-symbols: <text> like line of lt_text.
*   navigate from <CONTEXT> to <DROPDOWN1> via lead selection
  lo_nd_dropdown1 = wd_context->get_child_node( name = wd_this->wdctx_dropdown1 ).
*   get element via lead selection
  lo_el_dropdown1 = lo_nd_dropdown1->get_element(  ).
* navigate from <CONTEXT> to <DROPDOWN1> via lead selection
  lo_nd_dropdown1 = wd_context->get_child_node( name = wd_this->wdctx_dropdown1 ).

* navigate from <DROPDOWN1> to <DROPDOWN2> via lead selection
  lo_nd_dropdown2 = lo_nd_dropdown1->get_child_node( name = wd_this->wdctx_dropdown2 ).
* get element via lead selection
  lo_el_dropdown2 = lo_nd_dropdown2->get_element(  ).
*   get single attribute
  lo_el_dropdown1->get_attribute(
    exporting
      name =  `ACTION`
    importing
      value = lv_action ).
  zcl_sample=>get_text_line( exporting act       = lv_action
                                importing it_text   = lt_text ).
loop at lt_text assigning <text>.
    wa_attributes-action_1 = <text>-tdline.
    insert wa_attributes into table lt_attributes.
  endloop.
lo_nd_dropdown2->bind_elements( lt_attributes ). 

My Z class will fetch values for the Action of Dropdown1 (lv_action). And I'll pass the resulted values to my second dropdown.

Use the above concept, if you find anything not working, then please let me know.

Regards,

-Syed.

Edited by: wahid hussain syed on Oct 20, 2009 12:04 PM

Former Member
0 Kudos

hi,

You can add the value to the supply function. And finally add the value to the internal table which is used to populate the drop down by index.

or you can directly set the attribute binded drop down by index with the value.