cancel
Showing results for 
Search instead for 
Did you mean: 

Getting MDM Hierarchy table into a WebDynpro recursive tree

lakshmi_narayana2
Active Participant
0 Kudos

Hi

Can anybody let me know how to develop/build a webdynpro recursive tree with a MDM Hierarchy table.

Thanks in advance

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi,

For exposing hierarchy in WD view you need to use node with recursive children in the context and Tree/TreeNodeType UI elements in view layout.

For load hierarchy records you have to use RetrieveLimitedHierTreeCommand. You can load whole hierarchy (as I know, SP05 API have a bug - only first 1000 record can be loaded) or load hierarchy nodes on demand (using OnLoadChildren action of TreeNodeType element).

Refer to this example of loading child records:

// Context structure:

// Tree (model node, model class built from com.sap.mdm.data.Record interface)

// |-- Children (recursive child node repeating Tree node)

// |-- DisplayValue (string value attribute, TreeNodeType's text property bound here)

// |-- HasChildren (boolean value attribute, TreeNodeType's hasChildren property bound here)

// parentElem is element of node Tree or Children for which we must load child records, null for first level of hierarchy

private void fillNodeWithChildren(IPrivateHierarchySelectView.ITreeElement parentElem) {

// Determining RecordId of parent record and context node to which child records belong

RecordId parentRecordId = null;

if (parentElem != null) parentRecordId = parentElem.modelObject().getId();

IPrivateHierarchySelectView.ITreeNode parentNode =

parentElem == null

? wdContext.nodeTree()

: parentElem.nodeChildren();

// Loading children with RetrieveLimitedHierTreeCommand

try {

RetrieveLimitedHierTreeCommand retTreeCmd = new RetrieveLimitedHierTreeCommand(...); // use suitable constructor

if (parentRecordId != null) retTreeCmd.setRootNode(parentRecordId);

retTreeCmd.setResultDefinition(...); // don't forget set ResultDefinition

retTreeCmd.execute();

HierNode subRoot = retTreeCmd.getTree()

parentNode.invalidate();

// Processing loaded child records - add elements into parentNode

if (subRoot == null) return;

IPrivateHierarchySelectView.ITreeElement childElem;

HierNode childRecord;

HierNode[] children = subRoot.getChildren();

int count = children == null ? 0 : children.length;

for (int i = 0; i < count; i++) {

childRecord = children<i>;

childElem = parentNode.createTreeElement(childRecord);

childElem.setDisplayValue(childRecord.getDisplayValue());

childElem.setHasChildren(!childRecord.isLeaf());

parentNode.addElement(childElem);

}

if (parentElem != null) parentElem.setHasChildren(count > 0);

} catch (/* Some MDM Exceptions */) {}

}

Don't forget call fillNodeWithChildren(null) in wdDoInit for load first level of hierarchy.

Former Member
0 Kudos

The orignal message is [here|]. It's a shame copying other's posts!

former_member1166031
Participant
0 Kudos

How dare you sold him shame,. u stupid.. actually he helped him by spending his resources.. u are not fit to be in this community getlost..

u should be shame of using those statements..