cancel
Showing results for 
Search instead for 
Did you mean: 

Creating Nodes dynamically..

Former Member
0 Kudos

Hello All,

I have a business requirement that the data returned from a BAPI has to be split into sub-sets, and then displayed in seperate tables. I have identified a way to create the tables dynamically.

How do we create Context nodes on the fly (dynamically)? The requirement is that if the BAPI is returning 5 records, then I have to create 5 context nodes. Each of the node then can be attached to a table and displayed. The newly created 5 context nodes should have the same structure as the BAPI output (so that we can get a one-to-one mapping).

Thanks in advance,

PKS

Accepted Solutions (1)

Accepted Solutions (1)

dhruv_shah3
Active Contributor
0 Kudos

public void wdDoInit()

{

//@@begin wdDoInit()

IWDNodeInfo rootnodeInfo = wdContext.getNodeInfo();

IWDNodeInfo soNodeInfo = rootnodeInfo.addChild(

"SalesOrders",

null,

true,

false,true,

false,false,

true,

null,

null,

null);

soNodeInfo.addAttribute("OrderNo","ddic:com.sap.dictionary.integer");

soNodeInfo.addAttribute("SalesDate","ddic:com.sap.dictionary.date");

soNodeInfo.addAttribute("SalesRep","ddic:com.sap.dictionary.string");

soNodeInfo.addAttribute("LongText","ddic:com.sap.dictionary.string");

IWDNode soNode = wdContext.getChildNode("SalesOrders",0);

IWDNodeElement soElement = soNode.createElement();

soElement.setAttributeValue("OrderNo",new Integer(100));

soElement.setAttributeValue("SalesDate",new Date(System.currentTimeMillis()));

soElement.setAttributeValue("SalesRep","Dhruv Shah");

soElement.setAttributeValue("LongText","Printer Supplies");

soNode.addElement(soElement);

//@@end

}

Use this example to get some idea.....

Regards,

Dhruv Shah

Answers (2)

Answers (2)

Former Member
0 Kudos

Problem solved. Thanks

former_member485701
Active Participant
0 Kudos

Hi,

In following manner you can create nodes dynamically.

nodeInfo=wdContext.getNodeInfo().addChild("node_name", null,true, CMICardinality.MANY,CMICardinality.MANY, true, null);

IWDNode tableNode = wdContext.getChildNode(nodeInfo.getName(), IWDNode.LEAD_SELECTION);

Now in this table node you can add attributes in following manner.

nodeInfo.addAttribute("attribute","com.sap.dictionary.string");

Feel free to contact for queries ,

Regards,

Praveen