cancel
Showing results for 
Search instead for 
Did you mean: 

MDM Hierarchy Table Into Tree (Java WebDynpro)

Former Member
0 Kudos

Hello all,

I have a requirement of showing a MDM Hierarchy Table into Tree UI element.

These are the steps am following:

1) MDM Connectivity

2) Using RetrieveLimitedHierTreeCommand command to retrieve tree structure of the table

3) Using getChildren() method of each node to get the children

4) Made a tree ui element with a recursive node

Now since the Hierarchy table can reach any level of nodes how do i write code for dynamic tree node/leaf generation?

Please guide me through with detailed steps/code if possible?

Regards,

Yogesh Bhatia

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hello Arafat. I have one more requirement. I want to have a Tree such that only when its leaves are selected i should perform an action. However the recursive code you have given does not let me do that. I need to define nodes/leaves. I am using a context attribute boolean within my <Data Source> node for the same. Now in my recursive function how do i set the value of the attribute (boolean) so that for each node element (data about tree) i am aware that certain element is a leaf or a node. Can you kindly help me?

Regards,

Yogesh Bhatia

Former Member
0 Kudos

This has been solved. We need to add the following code lines apart from what you have mentioned.

if(hierNode.getChildren()[iChildCount].isLeaf())

{

obj.setVa_Action(false);

}

else

{

obj.setVa_Action(true);

}

Regards,

Yogesh Bhatia

Former Member
0 Kudos

Hi Yogesh,

After getting the HierNode you have to recursively populate the hierarchy tree using the below code:

 
		
  private void createHierarchyTree( parent_element, com.sap.mdm.data.HierNode HierNode)
  {
	if(HierNode != null && HierNode .getChildren() != null)
	{
		for(int iChildCount=0 ; iChildCount < HierNode .getChildren().length ; iChildCount++)
		{
			IPublic<comp name>.Iparent_element objTreeElement = parent_element.node<Recursive node name>().create<name>Element();
			objTreeElement.setattr1(HierNode.getChildren()[iChildCount].getDisplayValue());
			objTreeElement.setattr1_Recid(HierNode.getChildren()[iChildCount].getId().id);
			parent_element.node<Recursive node name>().addElement(objTreeElement);
// call the method recursively			
createHierarchyTree(objTreeElement, HierNode.getChildren()[iChildCount]);
		}
	}
  }

This will populate the tree, you need to create an action in the tree view and link it to TreeNode Type action property using which you can get the selected value.

Hope this helps!!

Cheers,

Arafat

Former Member
0 Kudos

Hello Arafat,

I am trying out the same what you have mentioned.

Can you please let me know what is parent_element here?

Also please let the me know the context you have designed. What types are attr1 and attr1_Recid?

Former Member
0 Kudos

Hi Yogesh,

I am using the below node structure in my solution:

ParentNode (Cardinality 0..n)

|___ Recursive node(repeatedNode property should point to ParentNode)

|___ Attr1 (String)

|___ Attr1_RecId(integer)

parent_element refers to the element of ParentNode created before calling the createHierarchyTree method.

Let me know if you have any other queries.

Cheers,

Arafat

Former Member
0 Kudos

Hi,

Can you also give me a code example how this method has been called with types of actual parameters?

How do i declare the parent_element type in code/when i define the method? What is its parameter type?

Regards,

Yogesh Bhatia

Former Member
0 Kudos

Hi Yogesh,

You can create the element like below:

objHierNode is the object you got using APIS from MDM.

IPublic<ControllerName>.IParentNodeElement parent_element = wdContext.nodeParentNode().createParentNodeElement();

Assign the values to the attributes of the node element:

parent_element.setAttr1("Hierarchy"); // this is the name you want to give to hierarchy

parent_element.setAttr1_RecId(objHierNode.getId().id);

wdContext.nodeParentNode().addElement(parent_element);

this.createHierarchyTree(objHierNode, parent_element);

Hope this helps!!

Cheers,

Arafat