cancel
Showing results for 
Search instead for 
Did you mean: 

Doubt in Multiselection in a table

Former Member
0 Kudos

Hi All,

I have a table and have to to multiselection.While doing the multiselection I have to pass the few things for the selected rows to a BAPI which will process and give the output accordingly.

In an action handler I am writing the following code:

//*****Trying the multiselection****//

IOPENITEMS_openElement tableEle = null;

IPrivateCreateResultIPView.IMultiNodeElement ele = wdContext.nodeMultiNode().createMultiNodeElement();

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

wdComponentAPI.getMessageManager().reportSuccess(" Size is :"+wdContext.nodeOPENITEMS_open().size());

boolean aa = wdContext.nodeOPENITEMS_open().isMultiSelected(i);

wdComponentAPI.getMessageManager().reportSuccess("Selected : "+i " : Val "aa);

if(aa){

wdComponentAPI.getMessageManager().reportSuccess(" Selected "+i);

tableEle = (IOPENITEMS_openElement)wdContext.nodeOPENITEMS_open().getElementAt(i);

ele.setMultiDocno(tableEle.getDOC_NO());

ele.setMultiItem(tableEle.getITEM());

ele.setMultiRep(tableEle.getREP_ITEM());

ele.setMultiSub(tableEle.getSUB_ITEM());

wdContext.nodeMultiNode().addElement(ele);

}

}

//****Ends here***//

here multiNode is a local View node that I have taken to collect the records or the data for the selected rows.

The Exception that i am getting

com.sap.tc.webdynpro.progmodel.context.ContextException: Node(CreateResultIPView.multiNode): cannot bind or add element, because it is already bound to a node

at com.sap.tc.webdynpro.progmodel.context.Node.prepareAddElement(Node.java:645)

at com.sap.tc.webdynpro.progmodel.context.Node.addElement(Node.java:631)

at com.accenture.pct.rrs.installmentplan.CreateResultIPView.onActionCreateInstallmentPlan(CreateResultIPView.java:462)

at com.accenture.pct.rrs.installmentplan.wdp.InternalCreateResultIPView.wdInvokeEventHandler(InternalCreateResultIPView.java:1597)

at com.sap.tc.webdynpro.progmodel.generation.DelegatingView.invokeEventHandler(DelegatingView.java:87)

Kindly give a solution to the problem.I have been struggling for the past one whole day.

looking forward to you.

Regards

DK

Accepted Solutions (1)

Accepted Solutions (1)

sridhar_k2
Active Contributor
0 Kudos

Hi DK,

It is simple. Bring that element into the for loop.like,

IPrivateCreateResultIPView.IMultiNodeElement ele = null;

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

ele = wdContext.nodeMultiNode().createMultiNodeElement();

//write your logic here

wdContext.nodeMultiNode().addElement(ele);

}

Hope it solved ur problem.Otherwise get back.

Regards,

SK

Former Member
0 Kudos

Hi SK,

Thanx for the reply..its working without any exception..but even after taking a node..still it is taking only the lastrecord..

I dont understand what is the other approach..

Let me know if you have any solutions.

Regards

DK

Answers (1)

Answers (1)

Former Member
0 Kudos

Try this


    int n = wdContext.nodeOPENITEMS_open().size();
    wdComponentAPI.getMessageManager().reportSuccess("Size of node OPENITEMS_open: " + n);
    for (int i = 0; i < n; i++)
    {
      boolean selected = wdContext.nodeOPENITEMS_open().isMultiSelected(i) || wdContext.nodeOPENITEMS_open().getLeadSelection() == i;
      if (selected)
      {
        wdComponentAPI.getMessageManager().reportSuccess("Element at index " + i + " is selected");
        IOPENITEMS_openElement src = wdContext.nodeOPENITEMS_open().getOPENITEMS_openElementAt(i);
        IMultiNodeElement tgt = wdContext.nodeMultiNode().createMultiNodeElement();
        wdContext.nodeMultiNode().addElement(tgt);
        tgt.setMultiDocno(src.getDOC_NO());
        tgt.setMultiItem(src.getITEM());
        tgt.setMultiRep(src.getREP_ITEM());
        tgt.setMultiSub(src.getSUB_ITEM());
      }
    }

Armin