cancel
Showing results for 
Search instead for 
Did you mean: 

Get selected elements from a table

Former Member
0 Kudos

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.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

*--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

Former Member
0 Kudos

Thanks Lekha..

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Santhosh,

Use this code to get the selected entries in separate internal table..

lo_nd = wd_context->get_child_node('Table_name').

CALL METHOD lo_nd->get_selected_elements

RECEIVING

set = lit_detail.

IF lit_detail[] IS NOT INITIAL .

LOOP AT lit_detail INTO lfl_detail.

CALL METHOD lfl_detail->get_static_attributes

IMPORTING

static_attributes = lfl_select.

APPEND lfl_select TO lit_select.

CLEAR lfl_select.

ENDLOOP.

Regards,

Simi A M