cancel
Showing results for 
Search instead for 
Did you mean: 

Problem with MultiLeadSelection in a table

Former Member
0 Kudos

Hi All,

I am still having the problem with the multilead selection in a table.

I am setting the table properties to multi and I have an event handler for the onaction property, named as leadselection.

I am writing the code below for the event handler.

public void onActionLeadSelect(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )

{

int selectedRow = firstNode.nodeOPENITEMS_open().getLeadSelection();

int sizeOfOpen = wdContext.nodeOPENITEMS_open().size();

IOPENITEMS_openElement element = (IOPENITEMS_openElement)firstNode.nodeOPENITEMS_open().getElementAt(selectedRow);

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

if(wdContext.nodeOPENITEMS_open().isMultiSelected(i)||selectedRow == i){

wdContext.currentContextElement().setMultiDocNumber(wdContext.nodeOPENITEMS_open().getOPENITEMS_openElementAt(selectedRow).getDOC_NO());

wdContext.currentContextElement().setMultiItemno(wdContext.nodeOPENITEMS_open().getOPENITEMS_openElementAt(selectedRow).getITEM());

wdContext.currentContextElement().setMultiRepItem(wdContext.nodeOPENITEMS_open().getOPENITEMS_openElementAt(selectedRow).getREP_ITEM());

wdContext.currentContextElement().setMultiSubitem(wdContext.nodeOPENITEMS_open().getOPENITEMS_openElementAt(selectedRow).getSUB_ITEM());

}

}

}

What i am trying to do is..On multiselection or on single leaad selection, I should pass the whole amount to the BAPI or the amount related to only the leadselection.

But when I am trying to run..this code..I am nt able to select in a multiple way..and more over if I press ctrl then I am able to make the other rows highlighted with orange color..but not normally and after making them highlighted also i am not able to pass the amount for all the selected rows..together..

Kindly suggest me..something..

Regards

DK

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

Try this ,

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

if(wdContext.nodeOPENITEMS_open().isMultiSelected(i)){

wdContext.currentContextElement().setMultiDocNumber(wdContext.nodeOPENITEMS_open().getOPENITEMS_openElementAt(i).getDOC_NO());

wdContext.currentContextElement().setMultiItemno(wdContext.nodeOPENITEMS_open().getOPENITEMS_openElementAt(i).getITEM());

wdContext.currentContextElement().setMultiRepItem(wdContext.nodeOPENITEMS_open().getOPENITEMS_openElementAt(i).getREP_ITEM());

wdContext.currentContextElement().setMultiSubitem(wdContext.nodeOPENITEMS_open().getOPENITEMS_openElementAt(i).getSUB_ITEM());

}

}

If you use the selectedRow variable in if condition, it will fetch only one row from table. Because the getLeadSelection() method gives the number of row which got selection on first click before pressing Ctrl key. So you can get only one value for leadselect. that's why the if loop failure for other selected rows.

regards

karthik

Former Member
0 Kudos

Hi Karthik,

I did in the same way,but still the problem remains the same.

And I am doing this on leadselection action handler.

If u have any other approach,then do let me know.

Regards

DK

sridhar_k2
Active Contributor
0 Kudos

Hi,

Use the below code. Not in Lead Selection.

ITableElement tableEle = null;

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

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

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

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

if(aa){

tableEle = (ITableElement)wdContext.nodeTable().getElementAt(i+1);

wdComponentAPI.getMessageManager().reportSuccess("Lead Selected Val " + tableEle.getName());

}

aa=false;

}

Regards,

Sridhar K

Former Member
0 Kudos

hi

Dipendra ,on the leadselectAction()(this action should be in view controller) write this code:

wdContext.node<yourbapinode>().node<ifanyothernode>().addElement(wdContext.node<yourbapinode>().<ifanyothernode>()().create<ifany node>Element(new <your Bapitableclass>));

Regards

Nidhideep

Answers (2)

Answers (2)

sridhar_k2
Active Contributor
0 Kudos

Hi DK,

Keep Your Logic in a Separate method(lets say getAmount()) not on LeadSelection Action Method.

Call this method before sending it to the BAPI.

Other wise every time it takes first row amount only.

If your not sure, print that amount in your method.

In your getAmount()

use the below code

ITableElement tableEle = null;

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

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

if(aa){

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

tableEle = (ITableElement)wdContext.nodeTable().getElementAt(i+1);

}

}

Regards,

Sridhar K

Former Member
0 Kudos

Hi

Try this

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

<i>if(wdContext.nodeOPENITEMS_open().isSelected(i))</i>{

wdContext.currentContextElement().setMultiDocNumber(wdContext.nodeOPENITEMS_open().getOPENITEMS_openElementAt(selectedRow).getDOC_NO());

wdContext.currentContextElement().setMultiItemno(wdContext.nodeOPENITEMS_open().getOPENITEMS_openElementAt(selectedRow).getITEM());

wdContext.currentContextElement().setMultiRepItem(wdContext.nodeOPENITEMS_open().getOPENITEMS_openElementAt(selectedRow).getREP_ITEM());

wdContext.currentContextElement().setMultiSubitem(wdContext.nodeOPENITEMS_open().getOPENITEMS_openElementAt(selectedRow).getSUB_ITEM());

}

}

Kind Regards

Mukesh