cancel
Showing results for 
Search instead for 
Did you mean: 

Creation of Copy and insert in Table

Former Member
0 Kudos

Hi guys,

I am new to Web Dynpro.I have created one table from SAP by calling of RFC Adaptive method. Now i want to create copy the table single or multiple rows and paste in same table.

Could anyone please send me that exact documentation for creation of copy and paste button.

Regards

Velu.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Pravesh,

Thanks for ur reply.I am trying to using ur code create same action but there i got some error. Bcoz i called one BAPI table from R/3. Then i was created two buttons and two actions. Is their anything else i need to create for my Project.

If u dont mind please send some link with full procedure.

Thanks

velu

pravesh_verma
Active Contributor
0 Kudos

Hi Klanthaivelu,

What is the error are you getting. I dont think it will show error becoz of the BAPI tables, since this copy and paste stuff is totally at the UI Level. It will be not effected by what backend are you having.

I hope you have added the code of copy and paste in these two action implementation.

Also you have to create one method as mentioned in my last post, which checks whether the row is empty or not.

Regards

Pravesh

PS: Consider rearding points if helpful.

Answers (1)

Answers (1)

pravesh_verma
Active Contributor
0 Kudos

Hi Kulanthaivelu,

There is no such exact documentation. But you can implement that using the code. You have to keep few things in mind for this particular code:

1) There should be one empty row where you want to paste the selected row.

2) You cannot copy a selected row on a row already having some data. If you want to do that you have to modify the code.

3) This code is not for multiple copy & paste. For doing that you can modify the code.

<b>Steps for Copy:</b>

1) Create a button and create a action for that say Copy

2) Write this code for implementation of this function:

public void onActionCopy(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )
  {
    //@@begin onActionCopy(ServerEvent)
  	int currentIndex = wdContext.node<having_the_attributes_for_column>().getLeadSelection();
  	IWDNodeElement ne1 = wdContext.node<having_the_attributes_for_column>().createElement();

  	WDCopyService.copyCorresponding(wdContext.node<having_the_attributes_for_column>().getElementAt(currentIndex),ne1);
  	ne = ne1;
    //@@end
  }

<b>Steps for Paste:</b>

1) Create a button and create a action for that say Paste.

2) Write this code for implementation of this function:

public void onActionPaste(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )
  {
    //@@begin onActionPaste(ServerEvent)
  	int currentIndex = wdContext.node<having_the_attributes_for_column>().getLeadSelection();
  	IWDNodeElement tempElement = wdContext.node<having_the_attributes_for_column>().getElementAt(currentIndex);

  	if(!isRowBlank(tempElement)){
  		wdThis.wdGetAPI().getComponent().getMessageManager().reportException("You can paste elements only in a blank row");
  	}
  	else{
  	  	WDCopyService.copyCorresponding(ne,wdContext.node<having_the_attributes_for_column>().getElementAt(currentIndex));
  	  	
  	}
    //@@end
  }

<b>isRowBlank Funtion:</b>

public boolean isRowBlank( com.sap.tc.webdynpro.progmodel.api.IWDNodeElement nodeElement )  {
    //@@begin isRowBlank()
  	IWDNode node = nodeElement.node();
  	Iterator itr = node.getNodeInfo().iterateAttributes();
  	while(itr.hasNext()){
  		IWDAttributeInfo info = (IWDAttributeInfo)itr.next();
  		if(nodeElement.getAttributeValue(info.getName())!= null){
  			return false;
  		}
  	}
  	return true;
    //@@end
  }

I hope this helps you!!

Regards

Pravesh

PS: Please consider rewarding points for helpful answers.