Skip to Content
avatar image
Former Member

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.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Best Answer
    avatar image
    Former Member
    Jan 03, 2012 at 01:16 PM

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

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jan 05, 2012 at 11:14 AM

    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

    Add comment
    10|10000 characters needed characters exceeded