Skip to Content

Recently by a query in SDN, was I introduced to this particular scenario of accessing a node dynamically in WebDynpro. The problem was that of getting a null pointer exception while execution. The topic might seem pretty simple; after all it is just a child’s game to create a node dynamically. So what is the big deal in accessing the dynamically created node. This was the impression the post gave me initially.

The scenario is as follows

Context
|
NodeA(Statically created)
|______NodeAB(Dynamic singleton)
           |________NodeABC(Dynamic NonSingleton)
                      |________NodeABCD(Dynamic NonSingleton)
                      |________AttbA
                      |________AttbB

The problem was however that there was no element being created; and that it was not able to access the NodeABC with the following code.

IWDNode node = wdContext.nodeNodeA.getChildNode(“NodeAB”,IWDNode.LEAD_SELECTION).getChildNode(“NodeABC”,0);

This code returned a null value and the node.createElement() caused the exception.

So I felt that this piece of code might be useful for someone who might be having a tough time with creation and accessing nodes with dynamic programming.

IPrivateDynAppView.INodeAElement ele=wdContext.createNodeAElement(); wdContext.nodeNodeA().addElement(ele);
IWDNodeInfo salesOrgs = wdContext.nodeNodeA().getNodeInfo();
IWDNodeInfo salesOrg = salesOrgs.addChild(“NodeAB”,null,true,true,true,false,false,true,null,null,null);
IWDNodeInfo salesOrgElement = salesOrg.addChild(“NodeABC”,null,false,true,true,false,false,true,null,null,null);
salesOrgElement.addAttribute(“AttbA”,”ddic:com.sap.dictionary.string”);
salesOrgElement.addAttribute(“AttbB”,”ddic:com.sap.dictionary.string”);
salesOrgElement.addChild(“NodeABCD”,null,false,true,true,false,false,true,null,null,null);

IWDNode node=wdContext.nodeNodeA().getChildNode(“NodeAB”,IWDNode.LEAD_SELECTION);
IWDNodeElement elem=node.createElement();
node.addElement(elem);
IWDNode divNode=wdContext.nodeNodeA().getChildNode(“NodeAB”,IWDNode.LEAD_SELECTION).getChildNode(“NodeABC”,0);
IWDNodeElement element=divNode.createElement();
divNode.addElement(element);
element.setAttributeValue(“AttbA”,”Text”);

String text=wdContext.nodeNodeA().getChildNode(“NodeAB”,IWDNode.LEAD_SELECTION).getChildNode(“NodeABC”,0).getElementAt(0).getAttributeAsText(“AttbA”);
wdThis.wdGetAPI().getComponent().getMessageManager().reportSuccess(text);

To report this post you need to login first.

2 Comments

You must be Logged on to comment or reply to a post.

  1. Former Member
    Hi

    When we try to create object to a WSDL from XI,it is asking for “array list parameter” in WebDynpro 7.0. Hence we are not able to solve the issue by following the way you have mentioned. Did u check the same in version 7.0 or your solution is for a specific version alone?..

    Regards,
    Kavitha.

    (0) 
    1. I think the node to which you are trying to add is of cardinality 1..1 (non multiple). In this case you would not be able to add elements instead u can set or bind the instance.

      I worked on this in NW04 and haven’t tried the Web Dynpro 7.0

      (0) 

Leave a Reply