Skip to Content
author's profile photo Former Member
Former Member

Need to loop through Recursive node

Hi Everyone,

I am having troubles looping through a node to get a boolean value called "Check".

Basically I am using the TreeNesteedInTable UI. One of the columns I display is the "Check" mentioned above. Basically the user can go through the tree structure and check his/her options. I should then be able to loop through this structure to get all the records "Checked". My application is not doing this.

At the moment I am looping through the top level node - think this is where my probelm is because this node can only be singleton! This means that I then have to loop through the Recusrsive node of this type to get the values as the recusrive is always non-singleton en must therefor contain the elements I am looking for. But, i do not know how tho get access to this node. Is this the correct way of doing it, or how should it be done otherwise?

Many thanks,

Christiaan

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • author's profile photo Former Member
    Former Member
    Posted on Nov 11, 2008 at 09:26 AM

    Say your context structure is:

    File (node, card=0:n)
    -- Children (recursive node -> File)
    -- <attributes>...
    

    Then you can visit this tree structure with

    void visit(IFileElement parent)
    {
      /* do something with parent ... */
    
      /* visit subtree */
      for (int i = 0; i < parent.nodeChildren().size(); ++i)
      {
        IFileElement child = parent.nodeChildren().getChildrenElementAt(i);
        visit(child);
      }
    }
    

    Armin

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      HI,

      I got it to work like this:

      public void addICAMForIncident( ) {

      //@@begin addICAMForIncident()

      IWDMessageManager msgMgr = wdComponentAPI.getMessageManager();

      try {

      int count;

      Bapi1240_Rc rootCause;

      IPublicEhs_icam.IAbsentOrFailedControlsElement existingAbsentOrFailedControlsElement;

      IPublicEhs_icam.IAbsentOrFailedControlsElement recursive;

      IPublicEhs_icam.IAbsentOrFailedControlsElement recursiveChildElement;

      IPublicEhs_icam.IAbsentOrFailedControlsNode recursiveChildNode;

      // if(wdContext.nodeAbsentOrFailedControls() != null){

      {

      // set header data:

      wdContext.currentHeader_CreateElement().setRecord_No(wdContext.currentHeader_GDElement().getRecord_No());

      wdContext.currentHeader_CreateElement().setRecno_Root(wdContext.currentHeader_GDElement().getRecno_Root());

      wdContext.currentHeader_CreateElement().setIncident(wdContext.currentGPInputNodeElement().getIPIncidentNum());

      //Top Level Node (Singleton)

      existingAbsentOrFailedControlsElement = wdContext.currentAbsentOrFailedControlsElement();

      //We need to go through the values of the RECURSIVE node as that is where the values are!

      //Each time we expand a node in the tree this recursive node is filled with values

      for(int i = 0;i<existingAbsentOrFailedControlsElement.nodeRecursiveAbsentOrFailedControl().size();i++)

      {

      recursiveChildNode = existingAbsentOrFailedControlsElement.nodeRecursiveAbsentOrFailedControl().nodeRecursiveAbsentOrFailedControl(i);

      for(int m = 0;m<recursiveChildNode.size();m++)

      {

      recursiveChildElement = recursiveChildNode.getAbsentOrFailedControlsElementAt(m);

      if(recursiveChildElement.getCheck())

      {

      //New line in the "table":

      rootCause = new Bapi1240_Rc();

      rootCause.setFunction("009");

      rootCause.setHierarchy_Key("EHS_IAL_STD");

      rootCause.setNode_Key(recursiveChildElement.getNODE_ID());

      rootCause.setRef_Recno(wdContext.currentHeader_GDElement().getRecord_No());

      rootCause.setRef_Object("IAL");

      rootCause.setRef_Recno_Smeas("0");

      rootCause.setPrimarykey("00000000000000000001");

      rootCause.setForeignkey("00000000000000000001");

      rootCause.setFlgfrgnkey(true);

      rootCause.setFlgprimkey(true);

      rootCause.setFlag_Selected(true);

      //add the line to the "table":

      createInput.addRootcause(rootCause);

      }//end if

      }//end for

      }// end for

      }

      // execute:

      wdContext.currentBapi_Bus1240_Create_InputElement().modelObject().execute();

      // invalidate the output structure:

      wdContext.nodeOutput_Create().invalidate();

      } catch (CMIException ex) {

      msgMgr.reportException(ex.getLocalizedMessage(), true);

      }

      //@@end

      }

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.