Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Get selected elements from a table

Hi all,

I have a requirement like i m enhancing standard component in that i have added one button on click of that i want fetch the selected line item from the table ( which is a normal table). selection mode is auto.

i tried with the following code.

DATA:lr_element TYPE REF TO if_wd_context_element,

lv_index TYPE i.

*--Get selected element

lr_element = wdevent->get_context_element( name = 'CONTEXT_ELEMENT' ).

****Here itself its throughing dump because lr_element is initial***************

*--get selected element index.

lv_index = lr_element->get_index( ).

can any one help me what is the wrong.. else suggest me how to get the selected elements from a table....

Thanks in advance.

Former Member
Former Member replied

*--Get selected element

lr_element = wdevent->get_context_element( name = 'CONTEXT_ELEMENT' ).

if lr_element is bound.

lv_index = lr_element->get_index( ).

endif.

Instead you can directly read the node if that row is a lead selected one.

lo_node = wd_context->get_child_node( name = 'EMP' ).  "Emp is node name
lo_ele = lo_node->get_lead_selection( ).
or 
lv_index = lo_node->get_lead_selection_index( ).

where is the above code written..is it written in OnLeadSelect event of the TABLE..

can any one help me what is the wrong.. else suggest me how to get the selected elements from a table....

As the selection mode is Auto there is no multiple selection..hence try to use the lead selection only.

Edited by: Lekha on Jan 3, 2012 6:47 PM

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question