cancel
Showing results for 
Search instead for 
Did you mean: 

How can i add selected element from one node to other node

carlin_willams
Participant
0 Kudos

Hi All

I have below requirement.

Say In the view leftside Available Languages ItemList Box Rightside Available Languages ItemList Box and Add & Remove Buttons in the middle.

User selects languages from Available Languages ItemList Box clicks on add it will adds to the Available Languages Item List box and ViceVersa with Remove Button.

1) I have created 2 nodes 1) AvlLang 2) SelLang both contains two attributes Key and Value.

2) For AvlLang node, Property : Data Dictonary binded with table. Values are coming fine in Available Languages ItemList Box.

3) How can i add selected language into the node Available Languages.

Please provide the code snippet how to achieve this.

BR

X- CW

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Apart from your request. I am just wondering about your choice of the UI element (itemList box) .I think Shuttle would be appropriate.

What i would do normally is use code generator tool (ctrl + F7 if i remember correctly ).

USe this tool to get the lead selection from Source node and set the node elemen to the target nodet. This will be a good learning for you to use the tool.

If you have trouble. Please let me know.

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Carlin,

Find below code to copy selected record from one node to another.

Here I am copying it_lips node into pack_mat node.

DATA: wa_temp TYPE REF TO if_wd_context_element,
            lt_temp TYPE wdr_context_element_set,
            count type c.

      DATA : lo_nd_it_lips TYPE REF TO if_wd_context_node,
             lo_el_it_lips TYPE REF TO if_wd_context_element,
             ls_it_lips TYPE wd_this->Element_it_lips,
             lt_it_lips TYPE wd_this->Elements_it_lips,
             ls_unpack TYPE wd_this->Element_unpack,
             lt_unpack TYPE wd_this->Elements_unpack.

* navigate from <CONTEXT> to <IT_LIPS> via lead selection
      lo_nd_it_lips = wd_context->path_get_node( path = `ZRETURN_DEL_CHANGE.CHANGING_3.IT_LIPS` ).

      CALL METHOD lo_nd_it_lips->get_selected_elements
        RECEIVING
          set = lt_temp.

* navigate from <CONTEXT> to <PACK_MAT> via lead selection
      lo_nd_pack_mat = wd_context->get_child_node( name = wd_this->wdctx_pack_mat ).

      LOOP AT lt_temp INTO wa_temp.
        CALL METHOD wa_temp->get_static_attributes
          IMPORTING
            static_attributes = ls_it_lips.

              ls_pack_mat-vgbel = ls_it_lips-vgbel.
              ls_pack_mat-vgpos = ls_it_lips-vgpos.
              append ls_pack_mat to lt_pack_mat.
              CLEAR ls_pack_mat.
      endloop.
        lo_nd_pack_mat->bind_table( new_items = LT_PACK_MAT
                                    SET_INITIAL_ELEMENTS = abap_true ).

Cheers,

Kris.

carlin_willams
Participant
0 Kudos

Hello Kris/Bal,

Thanks for your answers.

Kris @ : Provided is working fine.

I have 1 Item List Box for it_lips and second List Box is pack_mat. In between 2 listboxes ADD and Remove buttons are there.

If i click on ADD : selected items should add to the 2 Item listbox and shouldn't remailn in the 1 Item List Box.

When i click on Remove button viceversa should happend.

Could you please provide your suggestions if possible code snippet.

BR

CW

former_member199125
Active Contributor
0 Kudos

Same way in the remove button action.. follow below action

just in reverse way

Get the all the selected elements in 2nd node using get_selected_elements method.

bind those values to 1st node...

Regards

Srinivas

carlin_willams
Participant
0 Kudos

Hello

When i am adding elements from first list box (Node) to second node. It is adding to second list box.

BUT it is remaining in the first list (node)box i don't want those. ViceVersa case.

When i am removing elements from second list box (Node) to first node. It is adding to firstlist box.

BUT it is remaining in the second item list (node)box i don't want those.

How can i remove elements from the nodes for the above requirement.

I followed above code for two list boxes.

Please help with some code.

BR

-CW

Former Member
0 Kudos

if_wd_context_node has a method remove_element.

So when you add a element from itembox1 to itembox 2 then

remove the element from itembox 1 node.

say for example

lo_nd_itembox1->remove_element( lo_el_itembox1 ).

You can do the same coding for itembox2 using itembox2 node.