cancel
Showing results for 
Search instead for 
Did you mean: 

Code Error or SAP Bug?

Former Member
0 Kudos

Hello,

I have a strange problem. I have two tables, one with data, one w/o. When selecting an element from Table 1, I click a button and it removes it from table one and adds it to table 2, essentially sending it to the other table.

The problem I have is whenever I select the last element in Table 1, it moves ALL elements over to Table 2, and vice versa. I've checked my coding and don't see any errors.

Is this a code error or is this a known/unknown SAP bug?

Here's my code for the button:

//@@begin addPrograms()
int nodeSize = wdContext.nodeVnAvailablePrograms().size();
	for(int i=nodeSize-1; i>=0; i--)
	{
		if (wdContext.nodeVnAvailablePrograms().isMultiSelected(i) || wdContext.nodeVnAvailablePrograms().getLeadSelection() == i)
		{
			wdThis.addProgram(wdContext.nodeVnAvailablePrograms().getVnAvailableProgramsElementAt(i),wdContext.nodeVnAvailablePrograms(),wdContext.nodeVnSelectedPrograms());
			wdContext.nodeVnAvailablePrograms().removeElement(wdContext.nodeVnAvailablePrograms().getElementAt(i));
		}
	}
  //@@end

The cardinality for both nodes are 0..n

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hung,

The problem seems to be in method addProgram.

Could you post source of this method?

VS

Former Member
0 Kudos

Thanks for the reply Valery.

Here is the addProgram snipet.

    //@@begin addProgram()
	IWDNodeElement element = destNode.createElement();
	try
	{	
		element.setAttributeValue("Description",nodeElement.getAttributeAsText("Description"));
		element.setAttributeValue("Responsible_No",nodeElement.getAttributeAsText("Responsible_No"));
		element.setAttributeValue("Wbs_Element",nodeElement.getAttributeAsText("Wbs_Element"));		
		destNode.addElement(element);
	}
	catch(Exception ex)
	{
		wdComponentAPI.getMessageManager().reportMessage(IMessageReportsApp.ERROR_HANDLER, new Object[] {"ReportsApp","addProgram","",ex.getMessage()},false);
	}
    //@@end

Former Member
0 Kudos

Hung,

As I can see you are using only 2 parameters in addProgram method: source element and destination node.

However, you pass 3 parameters to addProgram: one element and two nodes, wdContext.nodeVnAvailablePrograms(),wdContext.nodeVnSelectedPrograms()).

Are you sure you are not confusing nodes when pass them to addProgram?

Valery Silaev

EPAM Systems

http://www.NetWeaverTeam.com

Former Member
0 Kudos

I just caught that myself Valery. Thanks.

But i'm positive I'm passing the correct nodes. Again, it all works except for when I try adding the last element in Table 1 into Table 2.

Former Member
0 Kudos

Hung,

I bet I catched this bug -- it is misunderstanding between you and WD

Try this:


int nodeSize = wdContext.nodeVnAvailablePrograms().size();
int lead = wdContext.nodeVnAvailablePrograms().getLeadSelection();
for(int i=nodeSize-1; i>=0; i--)
{
  if (wdContext.nodeVnAvailablePrograms().isMultiSelected(i) || lead == i)
  {
    wdThis.addProgram(
      wdContext.nodeVnAvailablePrograms().getVnAvailableProgramsElementAt(i),
      wdContext.nodeVnAvailablePrograms(),
      wdContext.nodeVnSelectedPrograms()
    );
    wdContext.nodeVnAvailablePrograms().removeElement(
      wdContext.nodeVnAvailablePrograms().getElementAt(i)
    );
  }
}

It seems that after you are deleting lead selected element WD select next one available. Or previous one if lead was latest element. Namely second option causes all elements to be removed

Valery Silaev

EPAM Systems

http://www.NetWeaverTeam.com

Message was edited by: Valery Silaev

Former Member
0 Kudos

Ahhhh. I'll give that a try. You are right, I am still trying to learn this thing.

Thanks for clearing things up!

Answers (1)

Answers (1)

Former Member
0 Kudos

bump post. any thoughts?