cancel
Showing results for 
Search instead for 
Did you mean: 

Need to loop through Recursive node

Former Member
0 Kudos

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

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

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

Former Member
0 Kudos

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

}