cancel
Showing results for 
Search instead for 
Did you mean: 

How to create dynamic tree based on BAPI

Former Member
0 Kudos

Hi

I am able to create dynamic tree based on flat file structure example given in SDN . But how to create the tree from BAPI directly.Also when I will be clicking on any leaf node of the tree some data related to the node will be passed to another view.

Regards

Ananda

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi Roy,

Create Tree and insert TreeNode under the Tree while designing the view.

Create RFC Model and create Model on the view .

Now You need to bind the outPut node to the tree UIElement.

Bind the TreeNods to the respective datanodes of the model.

Regards, Anilkumar

Former Member
0 Kudos

I'm afraid i need some sample code to implement this.

I can create the RFC Model.. not sure what you mean by create model on the view?

Is the ouput node the ouput node of the RFC Model?

Binding the tree nodes to the data nodes makes perfect sense.

julian

Former Member
0 Kudos

To display data in a tree you either need a recursive context node or a hierarchy of non-singleton nodes. Do you have such a structure under the BAPI output node?

If yes, you can map the view controller context to the component controller context to have access to these data from the view.

In the view layout, you create a Tree and bind its dataSource-property to the context node providing the data of the first level.

For each level, you can add TreeNodeType or TreeItemType elements and bind their dataSource-property to the subnode providing the tree nodes for that level.

Armin

Former Member
0 Kudos

What i'm trying to do is create an organizational structure.

Global>Region>Plant-->Corporation

The output from the RFC is a structure containing every possible combination for orgazational hierarchy. Basically a flat table with record for every possible combinaton of Region-Plant-Corporation. This data needs to be bound to a tree structure so that we can call BW queries based on that level. For example: Give me aged inventory for the SAP corporation within the plant Berlin that is located in the Europe region.

Now that you understand the business reason will the nodes that represent Region and Plant and corporation be non-singleton nodes or recursive? I was thinking a hierarchy of non-singleton nodes.

I can bind these nodes to the Region - Plant - Corporation elements returned from in the flat table structure. I will probably get duplicates as a specific Region will be listed multiple times for every possible combination of the data beneath it. I'm not so concerned about that right now as I want to make sure I understand how in Web Dynpro to bind the data to the tree.

Hopefully this makes some sense. Can you elaborate on how this may be constructed in context of the view?

Would i create a model node for region (0..n), model node for plant (0..n), and a model node for Corporation (0..n)?

Or does this sound totally incorrect?

julian

We have 3 regions over 50 plants and probably around 500 corporations.

Former Member
0 Kudos

If the BAPI output has not the structure needed to bind a Tree UI element against it, you have to create such a structure manually in the view controller context. Bind the Tree UI element as sketched below and (if needed), fill the tree incrementally using the "onLoadChildren" action at the TreeNodeType elements.


Context:

Regions (node, card=0:N)
-- Plants (node, card=0:N, singleton=false)
---- Corporations (node, card=0:N, singleton=false)

UI elements:

OrganizationTree: IWDTree
OrganizationTree.dataSource = "Regions"

RegionNode: IWDTreeNodeType
RegionNode.dataSource = "Regions"
RegionNode.onLoadChildren: "LoadPlantsForRegion" (action)

PlantNode: IWDTreeNodeType
PlantNode.dataSource = "Regions.Plants"
PlantNode.onLoadChildren: "LoadCorporationsForPlant" (action)

CorporationNode: IWDTreeItemType
CorporationNode.dataSource = "Regions.Plants.Corporations"

Action handler:

void onActionLoadPlantsForRegion(..., IWDNodeElement nodeElement)
{
  IRegionsElement region = (IRegionsElement) nodeElement;
  /* access BAPI output node to collect plants for this region */
}

Armin

Former Member
0 Kudos

Thanks Armin. This does make sense and I also found the SAP tutorial for integration of an SAP Tree Structure into a Table that gives an example of how those events can be created. With this I should be able to come up with something that fits my needs.

I will let u know.

julian

Former Member
0 Kudos

Once you execute the BAPI you'll have the result in the Output node. Then you can create the tree dynamically and populate it.

If you need to pass values to another view, map it to the component controller and pass it.

regards

Noufal