cancel
Showing results for 
Search instead for 
Did you mean: 

how to copy one table records into another table

Former Member
0 Kudos

hi experts...

i have two tables names as Table1 and Table2

Table1 has data coming from the backend system.

my requirement is copy the Table1 records into Table2

send me the procedure...

thanks

ramu.

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi,

if your RFC node is TargetRFC which is bind with the table 1,

and table 2 is bind with SourceValueNode then do like this,

IPrivate<Name>View.ISourceValueNode iSourceValueNode= wdContext.nodeSourceValueNode();

IPrivate<Name>View.ISourceValueElement iSourceValueElement;

IPrivate<Name>View.ITargetRFC Element iTargetRFCElement;

for(int i=0;i<wdContext.nodeTargetRFC().size();i++){

iTargetRFCElement = wdContext.nodeTargetRFC().getTargetRFCElementAt(i);

iSourceValueElement = iSourceValueNode.createSourceValueNodeElement();

iSourceValueElement.set<attribute name>(iTargetRFCElement.get<Attribute name>());

iSourceValueNode.addElement(iSourceValueElement);

iSourceValueNode.moveNext();

}

Regards,

ramesh

Former Member
0 Kudos

Hi Ramesh,

I have the same requirement. I followed your code and the values are getting copied into the second row instead of the first row of the table 2. Could you please help me to resolve this issue. I would appreciate your help.

Regards,

Gopal.

Former Member
0 Kudos

Hi,

There seems to be an element existing in the node when you copy. delete the element before copying.

Srini

Former Member
0 Kudos

Hey could be the cardinality issue.....make it o...n!! i hope issue will be fixed!!

snehal_kendre
Active Contributor
0 Kudos

HI,

If the structure of node of table1 and table2 are same then use copynode function.

if not then use

public void modeltovalue( com.sap.tc.webdynpro.progmodel.api.IWDNode source, com.sap.tc.webdynpro.progmodel.api.IWDNode target )
  {
    //@@begin modeltovalue()
    /**
     * method is reserved for filter use only.
     * table and context node used for filtering are filled with data by this method.
     * 
     **/
     
	if (source.size() !=0){
				target.invalidate();
				for (int i = 0; i < source.size(); i++ ){
    	
				IWDNodeElement telem = target.createElement();
				target.addElement(telem);
				source.moveTo(i);
				target.moveTo(i);
				IWDNodeElement selem = source.getCurrentElement();
				telem.setAttributeValue("attribute_1name",selem.getAttributeValue("attribute_1name"));
				telem.setAttributeValue("attribute_2name",selem.getAttributeValue("attribute_2name"));
....
....
...
...
	telem.setAttributeValue("attribute_n name",selem.getAttributeValue("attribute_n name"));
}
}

Former Member
0 Kudos

Hi,

use the following code

WDCopyService.copyElements(source, target);

Regards

Ayyapparaj