on 01-12-2006 7:02 AM
Hi
Can anybody let me know how to develop/build a webdynpro recursive tree with a MDM Hierarchy table.
Thanks in advance
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
94 | |
11 | |
11 | |
10 | |
9 | |
8 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.