on 03-05-2009 2:23 PM
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 ).
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
User | Count |
---|---|
87 | |
23 | |
11 | |
9 | |
8 | |
5 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.