cancel
Showing results for 
Search instead for 
Did you mean: 

delete records from table

Former Member
0 Kudos

Hi,

How to delete records from table/node in web dynpro frontend without deleting the actual records in sap backend system ?

Thanks,

Namarata.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

hi

if you are deleting the record from the table node on leadSelection of the table

then

int leadselection =wdcontext.nodeTableNodeName.getLeadSelection();

for(int i=0;i<wdcontext .nodeTableNode.size;i++)

{

if(wdcontext.nodeTableNodeName.isSelected(i) || leadselection==i)

{

IprivateViewName.IContextElement element = wdcoontext.nodeTablenodename.createtablenodenameelement();

wdcontext.nodetablenodename.removeelement(element);

}

}

try this should solve your problem

birojpatro
Contributor
0 Kudos

Hi Namrata,

If you have the value node to display data as a table in the view, you can delete the elements/records from the value node (can be any logic).

Then loop the latest value node to display in the table (view).

Hope This Helps.

Cheers!!!

Biroj Patro.

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi,

Just delete the node element directly from the node.Refer the below code.

Create one button & bind action to it.Implement the below code in the action method.

int i = wdContext.nodeXXX().getLeadSelection();

IWDNodeElement ele = wdContext.nodeXXX().getElementAt(i);

wdContext.nodeXXX().removeElement(ele);

XXX = node to which table is binded.

Hope it helps.

Regards

Shruti

Former Member
0 Kudos

Hi Namrata,

To delete records from table/node in web dynpro, use the following code in your action:

{

int tablesize = wdContext.nodeTable().size(); // This would give the size of the table

int leadSelection = wdContext.node<TableName>().getLeadSelection(); // To lead select every node of the table

for (int i = 0; i < tablesize; i++)

{

if (<Condition>)

{

wdContext.node<TableName>().removeElement(wdContext.node<TableName>).getElementAt(i));

// This would delete the particular node of the table from front end.

}

}

}

I hope this solves your purpose, If you are looking for something else, please revert back, I'll be happy to help you.

Cheers!!!

Umang

Former Member
0 Kudos

Hi

Write the following code.



public void onActiondelete(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )
  {
    //@@begin onActiondelete(ServerEvent)
	int n = wdContext.nodeTable().size();
		int leadSelected = wdContext.nodeTable().getLeadSelection();
	
		// loop backwards to avoid index troubles
		for (int i = n - 1; i >= 0; --i) {
		  if (wdContext.nodeTable().isMultiSelected(i) || leadSelected == i) {
			wdContext.nodeTable().removeElement(
			  wdContext.nodeTable().getElementAt(i));
		  }
		}
	
    //@@end
  }


Thanks

Abhilasha