cancel
Showing results for 
Search instead for 
Did you mean: 

WDCopyService.copyCorresponding only returns the last row

former_member300754
Participant
0 Kudos

Hi all,

I'm using WDCopyService.copyCorresponding to copy elements from work area to work area then add work area to Node. Please check out Java code below.

I'm trying to move data from nodeZPr_Account to Bapi node by looping nodeZPr_Account into model then using WDCopyService.copyCorresponding to move row values as below.


    if(wdContext.nodeZPr_Account().size() > 0){
		IPrivateMainView.IZPr_AccountNode acctNode = wdContext.nodeZPr_Account();
		IPrivateMainView.IIt_PraccountNode bapiNode = wdContext.nodeIt_Praccount();
		Bapimereqaccount acctModel = new Bapimereqaccount();
		
		for(int i=0; i<acctNode.size(); i++){
			IPrivateMainView.IZPr_AccountElement acctElem = acctNode.getZPr_AccountElementAt(i);
			
			WDCopyService.copyCorresponding(acctElem,acctModel);
			prNode.addIt_Praccount(acctModel);
		}
    };

Unfortunately, the return table shows the last row of acctNode for example:

acctNode

22222

222222

22222222

55555

555555

55555555

66666

666666

66666666

return table

66666

666666

66666666

66666

666666

66666666

66666

666666

66666666

Please advise me on this. Thanks in advance.

Peerasit

Accepted Solutions (0)

Answers (2)

Answers (2)

former_member300754
Participant
0 Kudos

Here is the solution:


    if(wdContext.nodeZPr_Account().size() > 0){
		IPrivateMainView.IZPr_AccountNode acctNode = wdContext.nodeZPr_Account();
		
		for(int i=0; i<acctNode.size(); i++){
			IPrivateMainView.IZPr_AccountElement acctElem = acctNode.getZPr_AccountElementAt(i)
			Bapimereqaccount acctModel = new Bapimereqaccount();
			
			WDCopyService.copyCorresponding(acctElem,acctModel);
			prNode.addIt_Praccount(acctModel);
		}
    };

o Move "Bapimereqaccount acctModel = new Bapimereqaccount();" within a loop

: )

former_member300754
Participant
0 Kudos

The problem is not about WDCopyService.copyCorresponding function.

Btw, i'm finding the solution why it returns duplicated rows.