cancel
Showing results for 
Search instead for 
Did you mean: 

How to clear a context node?

Former Member
0 Kudos

Hi Buddies,

I am implementing a functiont that provides all changed rows of a table. Therefore, I need to clear a context node each time the function is triggered. My code looks like this:

	  // remove all elements from node
	  for( int i=0; i < wdContext.nodeChangedCustomerRows().size(); i++ ){
		  wdContext.nodeChangedCustomerRows().removeElement(wdContext.nodeChangedCustomerRows().currentChangedCustomerRowsElement());
		  wdContext.nodeChangedCustomerRows().moveNext();
	  }
	  // iterate over all rows of customer table
	  for( int i=0; i < wdContext.nodeE_Customer().size(); i++ ){
		  
		  // check weather a row has changed
		  IE_CustomerElement e = wdContext.nodeE_Customer().getE_CustomerElementAt(i);

		  if (e.isChangedByClient()){
			// copy the changed row to the ChangedCustomerRow node
			  WDCopyService.copyCorresponding(wdContext.nodeE_Customer().getE_CustomerElementAt(i), 
					  wdContext.currentChangedCustomerRowsElement());
			  
			  // add new element to node and move from current to new one
			  wdContext.nodeChangedCustomerRows().addElement(new __Bic__Mrbkunde());
			  wdContext.nodeChangedCustomerRows().moveNext();

		  }
		  
		  wdContext.nodeE_Customer().moveNext();
	  }
	  
	  // trigger the RFC
	  wdThis.wdGetInfoObjectCustController().executeZ_Customer_Front_Controller();

So, the first couplpe of lines are supposed to clear the contex. However, it causes the conext to be empty ALWAYS. This may be due to the fact that there are different treads running or what not.

Does anybody know how to properly clear the context content?

Thanks, Johannes

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

hi

Instead of applying removeElement to the node,you can use wdContext.<nodename>.invalidate() to refresh the node.

Regards

sowmya.

Answers (5)

Answers (5)

Former Member
0 Kudos

C'mon guys.. there must be a way to do that? Any ideas?

Former Member
0 Kudos

Alright, thanks for helping me with this one...

Another problem resulted from this...

I need to fill ALL changes made in wdContext.nodeE_Customer() into wdContext.nodeChangedCustomerRows()

However, with this coding I only receive the changes made at this time. How can I have the isChangedByClient() flag not be reset between roundtrips?

  public void onActionValidateChangesCustomer(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )
  {
    //@@begin onActionValidateChangesCustomer(ServerEvent)
	  
	  // remove all elements from node
	  wdContext.nodeChangedCustomerRows().invalidate();
	  
	  // iterate over all rows of customer table
	  for( int i=0; i < wdContext.nodeE_Customer().size(); i++ ){
		  		  
		  // check weather a row has changed
		  IE_CustomerElement e = wdContext.nodeE_Customer().getE_CustomerElementAt(i);
		  if (e.isChangedByClient()){
			// copy the changed row to the ChangedCustomerRow node
			  WDCopyService.copyCorresponding(wdContext.nodeE_Customer().getE_CustomerElementAt(i), 
					  wdContext.currentChangedCustomerRowsElement());
			  
			  wdContext.nodeChangedCustomerRows().addElement(new __Bic__Mrbkunde());
			  // move from current to new one
			  wdContext.nodeChangedCustomerRows().moveNext();

		  }
		  
		  wdContext.nodeE_Customer().moveNext();
	  }
	  
	  // trigger the RFC
	  wdThis.wdGetInfoObjectCustController().executeZ_Customer_Front_Controller();
	  
	  // reset changed flag
	  //wdContext.wdGetAPI().resetChangedByClient();
	  

    //@@end
  }

Thanks, Johannes

Former Member
0 Kudos

hi,

if the context node is value node then use the below code to clear the context.

wdContext.nodeChangedCustomerRows().invalidate();

thanks,

ramesh

Former Member
0 Kudos

hi,

for clearing node use node().invalidate();

Regards

Trilochan

sureshmandalapu6
Active Contributor
0 Kudos

Hi Johannes Schnatz ,

remove context function removes all the contexts and gives the value under main nide.

where are change context we can explicitly specify under which context should the value should be...

Your problem will solve here

http://help.sap.com/saphelp_nw04/helpdata/en/ea/c1f1c4f47011d19a600000e8a4b41d/frameset.htm

For more information...

https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/0f6991e5-0901-0010-e0b0-dc2...

Just check this one also...good blog on context handling...

Remove context is different from the Context change.

Remove context does, it removes all the upper nodes of that particular node

where as Context change is used to set the context for that particular fields to satisfy the conditions

Context Change

http://help.sap.com/saphelp_nw04s/helpdata/en/35/fb8c4057d5701de10000000a1550b0/frameset.htm

Remove Context

http://help.sap.com/saphelp_nw04/helpdata/en/1f/ea0fb12403844bbb6c4cbc8a00cda9/content.htm

else use the Invalidate() function

Thanks

Suresh