cancel
Showing results for 
Search instead for 
Did you mean: 

Get lead select of table onclick of button

Former Member
0 Kudos

Hi ,

I want to capture the lead selected row field value onclick of a button. I have a table where user will select a row. But I need to capture the value of a field in the table on click of another button.

I used the code as below, which always fetches the first record. Need help on this.

DATA lo_nd_variant_tab TYPE REF TO if_wd_context_node.

DATA lo_el_variant_tab TYPE REF TO if_wd_context_element.

DATA ls_variant_tab TYPE wd_this->element_variant_tab.

DATA lv_variant LIKE ls_variant_tab-variant.

    • navigate from <CONTEXT> to <VARIANT_TAB> via lead selection*

lo_nd_variant_tab = wd_context->get_child_node( name = wd_this->wdctx_variant_tab ).

    • @TODO handle not set lead selection*

IF lo_nd_variant_tab IS INITIAL.

ENDIF.

    • get element via lead selection*

lo_el_variant_tab = lo_nd_variant_tab->get_element( ).

    • @TODO handle not set lead selection*

IF lo_el_variant_tab IS INITIAL.

ENDIF.

    • alternative access via index*

    • lo_el_variant_tab = lo_nd_variant_tab->get_element( index = 1 ).*

    • @TODO handle non existant child*

    • IF lo_el_variant_tab IS INITIAL.*

    • ENDIF.*

    • get single attribute*

lo_el_variant_tab->get_attribute(

EXPORTING

name = `VARIANT`

IMPORTING

value = lv_variant ).

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

hi,

You can even use

my_context_element = my_node->get_lead_selection( ) to get lead selection element.

or

lead_selection_index = my_node->get_lead_selection_index( ) to get the index of lead selection

and later read table at that particular index.

read table itab index lead_selection_index into wa_node. ( Supposing that itab has all the values of node ).

Go through this blog to get clarification on LeadSelection.

/people/thomas.szcs/blog/2006/07/24/basic-concepts--selection-vs-leadselection

Thanx.

Answers (1)

Answers (1)

arjun_thakur
Active Contributor
0 Kudos

Hi,

Try this reading the node rather then the attribute.

Create a OnLeadSelect method for the table and use the code given below.

Refer to this code:



 DATA lo_nd_cn_node TYPE REF TO if_wd_context_node.

  DATA lo_el_cn_node TYPE REF TO if_wd_context_element.
  DATA ls_cn_node1 TYPE wd_this->element_cn_node.

* navigate from <CONTEXT> to <CN_NODE> via lead selection
  lo_nd_cn_node = wd_context->get_child_node( name = wd_this->wdctx_cn_node ).


* get element via lead selection
  lo_el_cn_node = lo_nd_cn_node->get_element( ).


* get all declared attributes
  lo_el_cn_node->get_static_attributes(
    IMPORTING
      static_attributes = ls_cn_node1 ).

I hope it helps.

Regards

Arjun

Former Member
0 Kudos

Hi Arjun,

In My question I stated that i do not want to get the details based on onleadselect but rather onaction of a button.

Former Member
0 Kudos

HI,

-> Select the row in table which ever you want to select.

-> Create a button ui element with onaction as Go.

-> In the Onaction Go of button , get the selected row as :

DATA : ln_node type ref to if_wd_context_node,

ind type I.

ln_node = wd_context->get_child_node( ' CN_NODE' ).

ind = ln_node->get_lead_selection_index( ).

This way you would be able to get the row selected in the table.

->here CN_NODE is assumed to be your context node to which table is binded.

-> Now you can read the whole node using code wizard ( control+ F7).

-> All the values of table are now into table itab.

-> Read internal table at that particular index to get the selected Row of Table.

read table itabl index ind into work_area. ( work_area type itab).

I hope it will help you.

Thanx.

Edited by: saurav mago on Mar 6, 2009 8:20 PM

Former Member
0 Kudos

hi,

you can even use arjun's code with two additional lines for a particular context attribute but in OnAction of Button.

data lv_var type ls_cn_node1-Variant.

lv_var = ls_cn_node1-variant.

It should work fine.

Thanx.

Edited by: saurav mago on Mar 6, 2009 8:33 PM