cancel
Showing results for 
Search instead for 
Did you mean: 

Read the name of a parent node of a (static) Tree UI in WebDynPro Abap

Former Member
0 Kudos

hi Experts,

I have a tree control UI that has two levels of nodes from the Root node. Year & Month. Inside the Month Node there is always only one leaf that is called Current Schedule. User clicks on Current Schedule to view the Current Schedule. This could be any month's Current Schedule of the User's choice.

Thus, I need to know which month's current schedule is chosen by the user. My tree UI is an adaptation from WDT_TREE example from Std SAP example programs. For the chosen month to be known, I have to go up in the context node hierarchy by one level? (something like, get_parent of) from the current leaf. I am not sure how would i do it. Any pointers would be greatly helpful. I tried to pick up ideas from couple of tutorials and bunch of forum posts but I did not get anywhere.

The key to my requirement is just going up one level in the tree and get to know the 'name' of that node. That will tell me the Month of the User's choice.

Thanks in advance for your helpful answers/pointers

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

read the attribute associated with the selectedtext fo the month node.

  • Get the selected site

parent_element->get_attribute( EXPORTING name = ATTRIBUTE_NAME

IMPORTING value = l_VARIABLE ).

Thanks

Bala Duvvuri

Edited by: Bala Duvvuri on Feb 28, 2011 2:02 AM

Former Member
0 Kudos

Thanks Bala Duvvuri,

Could you please elaborate a bit more on your tip. I am a fledgling OO abapper not 'really' knowing as much OO as I should ..!!

By the way,I found out, I could apply the same OnAction method in the WDT_TREE example shown at the final leaf level to the node level as well to read the text of Month Node. It worked out and it meets my purpose with a rider..!

In order to get this Month node text for the selected 'Current Schedule' leaf, User have to click on the Month Node that opens the Current Schedule Leaf. If they clicked on the triangle beside the node, it still opens the Month Node to reveal the Current Schedule leaf, but the Month name wont be captured until User expressly clicked on Month Node first or the Folder Icon associated with it..!!

In other words, User cannot click on the left side triangle; if they did to reach the Current Schdule, the program wont work properly. This is no good, though i could talk my way through with the User to accept this. But technically i know it is possible to know the month name from a given Current Schedule leaf in the tree,though dont know how ..!!

Your bit more detailed reply would help me implement the more elegant solution than pushing the user to accept what i did.

As I await your reply i shall try to pick up from your tip.

In the meanwhile my tree has grown ..!! to have two more nodes, in which the contents need to be dynamically populated. Guess I am in for a long haul with the Tree UI

Looking to hear more. Thanks heaps again.

gill367
Active Contributor
0 Kudos

Hi

use context_element parameter of the action to fetch the element and then the node form it and then the parent element

corresponding to the node.

here is the sample code.


  data el type ref to if_wd_context_element.

  EL = wdEVENT->GET_CONTEXT_ELEMENT( 'CONTEXT_ELEMENT' ).
  data el1 type ref to if_wd_context_element.
  data nd type ref to if_wd_context_node.

  nd = el->get_node( ).
  el1 = nd->get_parent_element( ).
  data str type string.
  el1->get_attribute(
  exporting
    name = 'MONTH_A'
  importing
    value = str
      ).

thanks

sarbjeet singh